"Discounted" Subtotal

I attached a screenshot of my cart.

How do you make the subtotal the "discounted" total not the original price? It's confusing if the users see the discounted price on the table and the subtotal is not the discounted price.

Image icon checkout.jpg71.73 KB
Posted: Jan 7, 2013


akosipax on January 9, 2013

Ok, I was able to achieve this by implementing the hook_commerce_price_formatted_components_alter(&$components, $price, $entity). My code is:

function mymodule_commerce_price_formatted_components_alter(&$components, $price, $entity){
$components['base_price']['price']['amount'] = $components['base_price']['price']['amount'] +  $components['discount']['price']['amount'];

But now I'm wondering if this is actually safe to do or will it mess up calculations. Based on my testing and viewing the $components variable, changing the amount of the base_price doesn't affect the calculation of the order total. But I hope one of the commerce guys will confirm.

zpolgar on March 4, 2013

The solution is ok, if minimum one discounted product is in the cart.
When no discounted product the calculation give an error: Undefined index in modul line number 3.