2
我使用的是WooCommerce 3.0+,並且我在某個頁面上設置了產品價格。動態購物車項目定價不適用於WooCommerce 3.0+的訂單
$regular_price = get_post_meta($_product->id, '_regular_price', true);
$buyback_percentage = get_post_meta($_product->id, '_goldpricelive_buy_back', true);
$fixed_amount = get_post_meta($_product->id, '_goldpricelive_fixed_amount', true);
$markedup_price = get_post_meta($_product->id, '_goldpricelive_markup', true);
$buyback_price = ($regular_price - $fixed_amount)/(1 + $markedup_price/100) * (1-$buyback_percentage/100);
$_product->set_price($buyback_price);
價格正在更新我的車,但是當我點擊提交我的訂單,訂單的對象似乎沒有得到我定的價格。它需要原產品的價格。
有關我如何完成此任何想法?
感謝
你怎麼調用所有這些代碼行? – Reigel
我正在通過循環調用它 $ _product = wc_get_product($ id) – Elland
好吧,'$ _product-> set_price($ buyback_price);''會爲'$ _product'的這個時刻設置價格。它不會保存。 – Reigel