Hi. How can we help?

Add vendor(s) information in the customer completed order email

If you want add vendor(s) information in the customer completed order email you can add the followed code in functions.php of your theme:

add_action( 'woocommerce_email_after_order_table', 'yith_wcmv_add_vendor_information', 10, 4 );

if( ! function_exists( 'yith_wcmv_add_vendor_information' ) ){
function yith_wcmv_add_vendor_information( $order, $sent_to_admin, $plain_text, $email ){
$vendors = array();
$output = '';
if( class_exists( 'WC_Email_Customer_Completed_Order' ) && $email instanceof WC_Email_Customer_Completed_Order ){
/** @var WC_Order $order */
foreach ( $order->get_items() as $item ) {
if( $item instanceof WC_Order_Item_Product ){
$product_id = $item->get_product_id();

if( ! empty( $product_id ) ){
$vendor = yith_get_vendor( $product_id, 'product' );
if( $vendor->is_valid() && ! isset( $vendors[ $vendor->id ] ) ){
$vendors[ $vendor->id ] = $vendor;
}
}
}
}

if( ! empty( $vendors ) ){
$wrapper_start = '<div class="vendor-information">';
$wrapper_end = '</div>';

foreach ( $vendors as $k => $v ){
$fields = array(
'name' => __( 'Vendor', 'yith-woocommerce-product-vendors' ),
'location' => __( 'Address', 'yith-woocommerce-product-vendors' ),
'store_email' => __( 'Email', 'yith-woocommerce-product-vendors' ),
'telephone' => __( 'Telephone', 'yith-woocommerce-product-vendors' ),
);

$output .= '<ul style="margin-bottom: 15px;">';

foreach ( $fields as $key => $label ){
if( ! empty( $v->$key ) ){
$output .= sprintf( '<li><strong>%s</strong>: %s</li>', $label, $v->$key );
}
}

$output .= '</ul>';
}

}

if( ! empty( $output ) ){
$output = $wrapper_start . $output . $wrapper_end;
}

echo $output;
}
}
}
Was this article helpful?
1 out of 1 found this helpful

Back to Help Center >

Powered by Zendesk