Created
August 27, 2017 22:23
-
-
Save fervous/e259fa4564a5bb3cf239170111420bec to your computer and use it in GitHub Desktop.
add address & email to order, checkout, email wc vendors free
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
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 , 'billing_address_1', true ); | |
$address2 = get_user_meta( $vendor_id , 'billing_address_2', true ); | |
$city = get_user_meta( $vendor_id , 'billing_city', true ); | |
$store_postcode = get_user_meta( $vendor_id , 'billing_postcode', true ); | |
$state = get_user_meta( $vendor_id , 'billing_state', true ); | |
$address = ( $address1 != '') ? $address1 .', ' . $city .', ' . $state.', '. $store_postcode :''; | |
wc_add_order_item_meta( $item_id, apply_filters('wcvendors_sold_by_in_email', __('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', __('Email', 'wcvendors')), $email_vendor); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment