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