I have updated to WC 3.0.1 from 2.6.14.
My original code is as follows:
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
function add_custom_price( $cart_object ) {
$custom_price = 10; // This will be your custome price
foreach ( $cart_object->cart_contents as $key => $value ) {
$value['data']->price = $custom_price;
}
}
It is no longer updating the price in cart or minicart.
$product
properties. You should see a warning about this in thedebug.log
if you enabledWP_DEBUG
. You must use setters and getters now for product, order, order item, and coupon objects. – helgathevikingset_price()
in the source – helgatheviking