0

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!

0

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.

0

Hi you can change order of include and exclude price from default.phtml file.
please follow following path according to your theme path

public_html/app/design/frontend/ogani/ogani_default/Magento_Catalog/templates/product/price/amount/default.phtml
  • Thanks for the reply, I've altered the file 'public_html/app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/price/amount/default.phtml' and it's worked for the product and categories page, but the minicart and checkout still show them in the wrong order. Is there somewhere else I need to change them for the checkout and mini cart? – Dave Hook Oct 24 '17 at 15:06
  • What exactly did you change in default.phtml to change the order? I only see one <span> and then the Adjustments block. Moving the Adjustments block just moves the Excl. block. But I want the Excl. price displayed as regular and the Incl. price in the Adjustments block. – Jacques Mar 22 '18 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.