I'm trying to update product prices in cart programmatically but it's not working, here's the code I'm using:
function nivbook_woocommerce_before_calculate_totals( $cart ) {
foreach( $cart->get_cart() as $cart_item ) {
$cart_item['data']->set_price( 10 );
}
}
add_action( 'woocommerce_before_calculate_totals', 'nivbook_woocommerce_before_calculate_totals', PHP_INT_MAX, 1 );
What should I do?