WooCommerce Product Vendors
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
// add product fields "Vendor Email" and "Vendor Name" add_filter('woe_get_order_product_fields', function ($fields,$format) { $fields['vendor_email'] = array( 'label' => 'Vendor email', 'colname' => 'Vendor email', 'checked' => 1 ); $fields['vendor_name'] = array( 'label' => 'Vendor email', 'colname' => 'Vendor email', 'checked' => 1 ); return $fields; }, 10, 2); add_filter('woe_get_order_product_value_vendor_email', function ($value,$order, $item, $product,$itemmeta) { $vendor = WC_Product_Vendors_Utils::is_vendor_product( $item['product_id'] ); if ( $vendor AND !empty( $vendor[0] ) ) { $vendor_data = WC_Product_Vendors_Utils::get_vendor_data_by_id($vendor[0]->term_id); if ( ! empty( $vendor_data ) ) $value = $vendor_data['email']; } return $value; }, 10, 5); add_filter('woe_get_order_product_value_vendor_name', function ($value,$order, $item, $product,$itemmeta) { $vendor = WC_Product_Vendors_Utils::is_vendor_product( $item['product_id'] ); if ( $vendor AND !empty( $vendor[0] ) ) { $vendor_data = WC_Product_Vendors_Utils::get_vendor_data_by_id($vendor[0]->term_id); if ( ! empty( $vendor_data ) ) $value = $vendor_data['name']; } return $value; }, 10, 5); |