Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'woocommerce_before_calculate_totals', 'extra_price_add_custom_price', 9999, 1 );
- function extra_price_add_custom_price( $cart ) {
- if ( is_admin() && !defined('DOING_AJAX') )
- return;
- foreach ( $cart->get_cart() as $cart_item ) {
- echo $cart_item['data']->price; // this gives the price that i want but
- if( isset($cart_item['custom_data']['new_price']) ){
- $cart_item['data']->set_price( floatval($cart_item['custom_data']['new_price']) ); // here price is not updated
- }
- }
- }
Add Comment
Please, Sign In to add comment