"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.
Attachment | Size |
---|---|
checkout.jpg | 71.73 KB |
Comments
My Solution
Ok, I was able to achieve this by implementing the hook_commerce_price_formatted_components_alter(&$components, $price, $entity). My code is:
<?php
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.
The solution is ok, if
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.
Any updates on this? This is
Any updates on this? This is what I'm looking for. Thanks.