Created
December 17, 2015 21:11
-
-
Save bentasm1/024426b661193c7fd3a7 to your computer and use it in GitHub Desktop.
WC Vendors - Adds vendors email address to orders for admin, vendor, and buyer
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
/* WC Vendors - Adds vendors email address to orders for admin, vendor, and buyer */ | |
remove_action( 'woocommerce_add_order_item_meta', array('WCV_Vendor_Shop', 'add_vendor_to_order_item_meta'), 10, 2 ); | |
add_action( 'woocommerce_add_order_item_meta', 'ritzy_add_vendor_to_order_item_meta', 10, 2); | |
function ritzy_add_vendor_to_order_item_meta( $item_id, $cart_item) { | |
$vendor_id = $cart_item[ 'data' ]->post->post_author; | |
$vendor_data = get_userdata( $vendor_id ); // Fetch vendor data as array | |
$vendor_email = $vendor_data->user_email; // Store email as a string | |
$sold_by = WCV_Vendors::is_vendor( $vendor_id ) ? sprintf( WCV_Vendors::get_vendor_sold_by( $vendor_id ) ): get_bloginfo( 'name' ); | |
$sold_by_and_email = $sold_by . ' - ' . $vendor_email; | |
wc_add_order_item_meta( $item_id, apply_filters('wcvendors_sold_by_in_email', __('Sold by', 'wcvendors')), $sold_by_and_email); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment