我正在尝试使用以下函数更改购物车中的产品价格:
add_action( 'woocommerce_before_shipping_calculator', 'add_custom_price'
);
function add_custom_price( $cart_object ) {
foreach ( $cart_object->cart_contents as $key => $value ) {
$value['data']->price = 400;
}
}
在WooCommerce 2.6.x版本中,它正常工作,但在3.0+版本中不再工作。
我该如何使其在WooCommerce 3.0+版本中正常工作?
谢谢。