Skip to content

Instantly share code, notes, and snippets.

@kloon
Last active October 25, 2016 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kloon/6249945 to your computer and use it in GitHub Desktop.
Save kloon/6249945 to your computer and use it in GitHub Desktop.
WooCommerce Product Enquiry Form send enquiry to vendor
<?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;
}
?>
@Arkymedes
Copy link

Arkymedes commented Oct 25, 2016

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment