2017-03-16 7 views
1

チェックアウトページで、商品の前に各ベンダーの送料を表示する必要があります。
チェックアウトページで各商品の送料を表示するにはどうすればいいですか? Woocommerce

アレイ([全国] => [国際] => [handling_fee] => [:私は

get_post_meta($cart_item['product_id'] , '_wcv_shipping_details', true); 

しかし、のような空白の値でこのリターンで試してみましたenter image description here

[national_disable] => [national_disable] => [national_free] => [international_qty_override] => [international_disable] => [international_free] =>)

+0

それは、**(get_post_meta 'で最後の引数を**配列を返すだとして)'それは戻っています* ...またとして** 'false'を** *(とない' true'を)しなければなら空の値を持つキーの配列です。つまり、その出荷の詳細について実際に商品に何も定義されていないことを意味します。 – LoicTheAztec

答えて

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); 
} 
+0

どうすればいいですか? –

+0

ありがとうございますページを追加しました –

関連する問題