Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'woocommerce_email_recipient_auction_fail', 'custom_add_vendor_to_email_recipients', 50, 2 );
- add_filter( 'woocommerce_email_recipient_auction_finished', 'custom_add_vendor_to_email_recipients', 50, 2 );
- add_filter( 'woocommerce_email_recipient_auction_relist', 'custom_add_vendor_to_email_recipients', 50, 2 );
- add_filter( 'woocommerce_email_recipient_bid_note', 'custom_add_vendor_to_email_recipients', 50, 2 );
- function custom_add_vendor_to_email_recipients( $recipient, $object ) {
- if ( ! is_object( $object ) ) {
- return $recipient;
- }
- $key = false;
- $author_info = false;
- $arrayrec = explode( ',', $recipient );
- $post_id = method_exists( $object, 'get_id' ) ? $object->get_id() : $object->id;
- $vendor_id = WC_Product_Vendors_Utils::get_vendor_id_from_product( $post_id );
- if ( ! empty( $vendor_id ) ) {
- $vendor_data = WC_Product_Vendors_Utils::get_vendor_data_by_id( $vendor_id );
- $vendor_email = $vendor_data['email'];
- }
- if ( $vendor_email ) {
- $recipient = str_replace( '[woocommerce-product-vendor]', $vendor_email, $recipient );
- } else {
- $recipient = str_replace( '[woocommerce-product-vendor]', '', $recipient );
- }
- return $recipient;
- }
Advertisement
Add Comment
Please, Sign In to add comment