Created
September 13, 2015 21:04
-
-
Save bentasm1/714bf1be90ee96f6aefe to your computer and use it in GitHub Desktop.
Add Vendors Email after Shop Name to Email & Thank You Pages
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
/* This will add vendors email address after their Shop Name in WC Vendors */ | |
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', 'custom_add_vendor_to_order_item_meta', 10, 2); | |
function custom_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