Skip to content

Instantly share code, notes, and snippets.

@fervous
Created August 20, 2017 03:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fervous/d44c627f4a1685ba8dec01ceb8cd1fbf to your computer and use it in GitHub Desktop.
Save fervous/d44c627f4a1685ba8dec01ceb8cd1fbf to your computer and use it in GitHub Desktop.
Add Vendor Address email and Info to Customer emails and Order Confirmation WC Vendors
add_action( 'woocommerce_add_order_item_meta', 'bwd_add_vendor_to_order_item_meta', 10, 2);
function bwd_add_vendor_to_order_item_meta( $item_id, $cart_item) {
$vendor_id = $cart_item[ 'data' ]->post->post_author;
// build up address
$address1 = get_user_meta( $vendor_id , '_wcv_store_address1', true );
$address2 = get_user_meta( $vendor_id , '_wcv_store_address2', true );
$city = get_user_meta( $vendor_id , '_wcv_store_city', true );
$store_postcode = get_user_meta( $vendor_id , '_wcv_store_postcode', true );
$address = ( $address1 != '') ? $address1 .', ' . $city .', '. $store_postcode :'';
wc_add_order_item_meta( $item_id, apply_filters('wcvendors_sold_by_in_email', __('<br>Address', 'wcvendors')), $address);
}
add_action( 'woocommerce_add_order_item_meta', 'email_add_vendor_to_order_item_meta', 10, 3);
function email_add_vendor_to_order_item_meta( $item_id, $cart_item) {
$vendor_id = $cart_item[ 'data' ]->post->post_author;
$email_vendor = get_userdata( $vendor_id )->user_email;
wc_add_order_item_meta( $item_id, apply_filters('wcvendors_sold_by_in_email', __('<br>Email', 'wcvendors')), $email_vendor);
}
@ThemeMetro
Copy link

ThemeMetro commented Jul 18, 2018

Could you help me, Its not change values if vendors change from settings, I want its dynamically.

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