Overriding price
-
After updating to woocommrce 3.0 the overriding price function no longer works. This what I have in my functions.php file:
function calculate_cart_total( $cart_object ) {
/* additional price that has to be added */
$additionalPrice = 3;
foreach ( $cart_object->cart_contents as $key => $value ) {
/* Check for the value ( or it could be any condition logic ) */
/* Each custom field’s key would be prefixed withwccpf_
*/
if( isset( $value[ “wccpf_logo_1” ] ) && ( $value[ “wccpf_logo_1” ] == “rose”) ) {
// change the price
$orgPrice = floatval( $value[‘data’]->price );
$value[‘data’]->price = ( $orgPrice + $additionalPrice );
}
}
}
add_action( ‘woocommerce_before_calculate_totals’, ‘calculate_cart_total’, 99 );Any help will be greatly appreciated.
thanks
- The topic ‘Overriding price’ is closed to new replies.