我需要在结帐页面上显示每个供应商在产品前面的运费。 enter image description here
我尝试了
get_post_meta($cart_item['product_id'] , '_wcv_shipping_details', true);
但是这个返回的空白值如:
数组([national] => [国际] => [handling_fee] => [national_qty_override] => [national_disable] => [national_free] => [international_qty_override] => [international_disable] => [international_free] =>)
答案 0 :(得分:0)
我认为您正尝试在订单详情页面上访问购物车对象。下订单后,购物车对象将变空。您需要从订单对象中获取商品,然后获取每件商品的运费。
// You can use this piece of code on thank you page (after order is placed)
$order = new WC_Order( $order_id );
$order_item = $order->get_items();
foreach( $order_item as $product ) {
$prodct_name[] = $product['name'];
// here you will get product id and you can use that to get shipping details
get_post_meta($product['product_id'] , '_wcv_shipping_details', true);
}