我正在尝试使用以下功能在购物车中更改产品价格:
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;
}
}
Run Code Online (Sandbox Code Playgroud)
它在WooCommerce版本2.6.x中正常工作,但在3.0+版本中不再有效
如何让它在WooCommerce版本3.0+中运行?
谢谢.