Support » Plugin: Role Based Price For WooCommerce » Product Total price on cart page

  • This plug-in does what it says in their description without any error.

    But i am trying to add an extra fee on user input

    Issues: when i disable the plug-in it works fine but if i enable the plug-in i am not able to update the total price of each product on cart page.

    can you please guide in this matter or the hook you are using to modify the price.

    <code>
    // Set the new calculated cart item price
    add_action( 'woocommerce_before_calculate_totals', 'extra_price_add_custom_price', 999, 1 );
    function extra_price_add_custom_price( $cart ) {
    	if ( is_admin() && !defined('DOING_AJAX') )
    		return;
    
    	foreach ( $cart->get_cart() as $cart_item ) {
    		if( isset($cart_item['custom_data']['new_price']) ){
    			$cart_item['custom_data']['new_price'];
    			$cart_item['data']->set_price( floatval($cart_item['custom_data']['new_price']) );
    		
    		}
    	}
    }
    
    </code>
  • The topic ‘Product Total price on cart page’ is closed to new replies.