Last active
October 25, 2016 10:08
-
-
Save kloon/6249945 to your computer and use it in GitHub Desktop.
WooCommerce Product Enquiry Form send enquiry to vendor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'product_enquiry_send_to', 'wc_product_enquiry_to_vendor', 10, 2 ); | |
function wc_product_enquiry_to_vendor( $email, $product_id ) { | |
$vendors = get_product_vendors( $product_id ); | |
if ( ! empty( $vendors ) ) { | |
$emails = array(); | |
foreach( $vendors as $vendor ) { | |
foreach( $vendor->admins as $admin ) { | |
$emails[] = $admin->data->user_email; | |
} | |
} | |
return $emails; | |
} | |
return $email; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I'm getting the following error when adding this snippet on my website:
PHP Fatal error: Call to undefined function get_product_vendors()
Apparently this does not work anymore?
Thank you in advance,
Arky
EDIT: Disregard my comment. A misplaced brace made the function a nested function in my functions.php file. Thanks!