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. (see screenshot attached)

I tried to achieve this by implementing the hook_commerce_price_formatted_components_alter(&$components, $price, $entity):

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 I'm not sure 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.

CommentFileSizeAuthor
Checkout.jpg71.73 KBakosipax

Comments

rszrama’s picture

Status: Active » Closed (fixed)

This is a safe and perfect solution.