Home Forums WC Vendors Pro Support Get Vendor ID on functions.php

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

  • This topic has 4 replies, 3 voices, and was last updated 7 years ago by Anna.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #59264
    Diego
    Participant

    Hi there!

    I’m creating a custom contact form inside each vendor page.
    So i’ll have a link “talk to vendor” and a Contact Form 7 will show up in a popup form.
    I’m using a custom plugin to set recipient dynamically and send mail to each vendor.

    This is my code on functions.php:

    function wpcf7_custom_vendor_contact($recipient, $args=array()) {

    $vendor = get_user_by(id, $vendor_id );
    $vendor_mail = $vendedor->user_email;
    
      if (isset($args['vendor-hidden-field'])) {
        if ($args['vendor-hidden-field'] == 'vendor-hidden-field') {
          $recipient = $vendor_mail;
        } 
      }
      return $recipient;
    } 

    The problem is… how can I get $vendor_id ?
    This script is running at the vendor shop page.

    I’ve tried to use this code:

    $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
    $vendor_id   = WCV_Vendors::get_vendor_id( $vendor_shop );

    But it isn’t work…
    could you help me?

    Best regards 😉

    #59286
    Diego
    Participant

    Just a little update…

    This script is running by AJAX after user post the Contact Form 7 form on the Vendor Shop Page…
    The plugin run in an action called wpcf7_before_send_mail

    I don’t know if this change things, but I think this info could be important.

    Many thanks

    #59342
    DELETE
    Participant

    The contact form should provide you with a user ID for the vendor you’re trying to contact. You should be able to use that as the vendor ID, since it would be the same.

    #60206
    Diego
    Participant

    I’m sorry, but it’s not true.

    When the form is in Product Page, I can use the Contact Form 7 tag called post_author, because in a product page Vendor is the Author and its works fine.

    But, in Shop Page, vendor isn’t the author and I need to try an alternate method.
    If I can force in php WordPress to say that Vendor is the Author Page, its a way, but, i don’t know how to do that.

    In that case, I need to use the code above to collect the $vendor_id and get his mail in that function.
    So, could anyone help me HOW TO GET $vendor_id in this method?

    Many thanks guys.

    #60220
    Anna
    Member

    Hmm..
    Perhaps try:

    if ( is_shop() ) { 
    		$vendor_shop 		= urldecode( get_query_var( 'vendor_shop' ) );
    		$vendor_id   		= WCV_Vendors::get_vendor_id( $vendor_shop );
    }
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.