This relates to Magento 2.1.3. In final_price.phtml, when there is a special price, the regular price (or "old price") is also displayed.

Currently, my shop is set to display prices Excluding and Including Tax. The special price shows as both Excluding and Including, but the regular price shows only Including.

I need to change this so that I have the regular prices shown as either Excluding tax only, or both Excluding and Including tax.

The default code to display the regular price is:

<span class="old-price">
    <?php /* @escapeNotVerified */ 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
    ]); ?>

Unless I have missed a trick, it doesn't appear possible to change much in the behaviour/format of the amount rendering process. I've checked Magento's documentation for the pricing model which doesn't appear to have an answer for this situation.

The only way I've found is to remove the "skip_adjustments" line. This causes both Regular ex-vat and inc-vat prices to show, but it has a nasty unwanted side effect: on the Product page, the special price will be adjusted by JavaScript to the regular price. This renders this method pretty much unworkable.

Is there a better way to achieve this?


I think the key lies in the skip_adjustments-argument. The whole incl. / excl. tax is handled by other modules that do adjustments (like the Tax, MSRP and WEEE modules).

If you set skip_adjustments to false the result will be that the old price is rendered with both including and excluding tax:

echo $block->renderAmount($priceModel->getAmount(), [
    'display_label'     => __('Regular Price'),
    'price_id'          => $block->getPriceId('old-price-' . $idSuffix),
    'price_type'        => 'oldPrice',
    'include_container' => true,
    'skip_adjustments'  => false    // <-- see what I did here?

I ran into the same issue. I'm using CSS to effectively hide the old incl. price though.

Edit: Hm, now I'm running into the issue that when you do it like this there is some JavaScript on the product detail page that shows the old price excluding tax as being the new price excluding tax. I'll post an update here if I can find the problem.

Edit #2: Copying Magento_Tax/view/base/templates/pricing/adjustment.phtml to my own theme and stripping out the ID and some data-attributes seem to do the trick. However, I don't know what other issues this might cause:

<span data-label="<?php echo $block->escapeHtml(__('Excl. Tax')); ?>"
      class="price-wrapper price-excluding-tax">
    <span class="price"><?php echo $block->getDisplayAmountExclTax() ?></span>

It would be nice to see if Magento is going to support this feature out-of-the-box.

  • More precisely remove following line from adjustment.phtml: data-price-type="basePrice" – Arvind07 Feb 22 '18 at 13:33

In the end, I had to just forget about renderAmount() and just do it manually:

<span class="old-price">
    <span class="price-label">Regular Price</span>
    <span class="price-wrapper price-excluding-tax">
    <?php /* @escapeNotVerified */ echo '£'.$priceModel->getAmount()->getBaseAmount(); ?>

For more "properness", I think I could have also tried using render(), but the above is OK for my needs.

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.