I'm trying to find the best way to change the order in which magento 2 displays the product(s) total for included and excluded tax. By default magento shows the price including tax, then the price excluding tax. But I want to swap that around so the price excluding tax is first and including tax is second.
I've managed to do this for the product page by changing the final_price.phtml
file in my theme:
Magento_Catalog\templates\product\price\final_price.phtml
by swapping around the span tags:
<span class="old-price">
<?php echo $block->renderAmount($priceModel->getAmount(), [
'display_label' => __('Regular Price'),
'price_id' => $block->getPriceId('old-price-' . $idSuffix),
'price_type' => 'oldPrice',
'include_container' => true,
'skip_adjustments' => true
]); ?>
</span>
<span class="special-price">
<?php echo $block->renderAmount($finalPriceModel->getAmount(), [
'display_label' => __('Special Price'),
'price_id' => $block->getPriceId('product-price-' . $idSuffix),
'price_type' => 'finalPrice',
'include_container' => true,
'schema' => $schema
]); ?>
</span>
The problem is it still shows the default order in the mini-cart and checkout areas. Do I need to edit template files for cart and checkout too (and which ones), or is there a better way to change the order across the entire site, e.g a layout, config setting somewhere or modification?
Any help much appreciated!
Best Answer
I found the best solution for this was to use CSS instead of trying to adjust the core PHP and template files by setting display: flex for the parent element div container then setting order: css parameter to change the price containers position.