Magento2: Old prices are hidden in v2.1.5

Created on 10 Apr 2017  路  10Comments  路  Source: magento/magento2

Preconditions


  1. Magento v2.1.5
  2. Developer mode

Steps to reproduce

  1. Set up some products with special prices (or install sample data)
  2. Go to a category page that shows a product with special price
  3. 3.

Expected result

  1. The old price should be displayed with a strike-through style.

Actual result

  1. The old price is hidden; only the special price is displayed. The old price used to be displayed in v2.1.2, but when we upgraded to v2.1.5 it disappeared. After looking in here now I know why:

vendor/magento/module-configurable-product/view/base/templates/product/price/final_price.phtml

<?php if ($block->hasSpecialPrice()): ?>
    <span class="special-price">
        <?php /* @escapeNotVerified */ 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>
    <span class="old-price sly-old-price no-display">
        <?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
        ]); ?>
    </span>
<?php else: ?>

What is the reason for adding no-display to the old price? If anything, to show old price or not should be a configurable option in Admin.

Tax Cannot Reproduce Format is valid needs update bug report

Most helpful comment

Quick workaround to add this code at line 51 (before <?php else: ?>) in final_price.phtml:

<?php elseif($block->isProductList() && $block->hasSpecialPrice()): ?>

    <span class="special-price">
        <?php /* @escapeNotVerified */ 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>

     <span class="old-price">
        <?php /* @escapeNotVerified */ echo $block->renderAmount($priceModel->getAmount(), [
            'display_label'     => __('Regular Price'),
            'price_type'        => 'oldPrice',
            'include_container' => true,
            'skip_adjustments'  => true
        ]); ?>
    </span>

All 10 comments

I have the same question @thdoan , did you find any further info about this?
Did you change this? Looks pretty straight forward but were there any issues pop up?

Quick workaround to add this code at line 51 (before <?php else: ?>) in final_price.phtml:

<?php elseif($block->isProductList() && $block->hasSpecialPrice()): ?>

    <span class="special-price">
        <?php /* @escapeNotVerified */ 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>

     <span class="old-price">
        <?php /* @escapeNotVerified */ echo $block->renderAmount($priceModel->getAmount(), [
            'display_label'     => __('Regular Price'),
            'price_type'        => 'oldPrice',
            'include_container' => true,
            'skip_adjustments'  => true
        ]); ?>
    </span>

The workaround doesn't work for me. I use Magento 2.1.6. My special price conf products are not flagged and without old price in the catalog list view. It is not a css display-no thing. It is not there in the source.

Workaround from @annejan89 worked for me, @flipflap was line 41 for me. clean cache and worked.

I'm a bit confused why this was ever changed? It would be good if this was a configuration option or something.

@thdoan We cannot reproduce this issue as described. Please provide the detailed steps we must follow to reproduce this issue. In addition, identify the web server you are running, the versions of PHP and MySQL, and any other information needed to reproduce your issue.

@thdoan we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.

@magento-engcom-team having the same issue on ee2.1.7

JS is hiding this old price for some reason on product page, when it's a configurable product, which has a child product with a special price.

Seems to be coming from Magento_Catalog/js/price-box.js, which is hiding it if it has the css class sly-old-price. not sure why it would do this?

Magento_Catalog/js/price-box.js line 148

$('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({
    data: price
}));

Actually, it's not a bug on the product page magento2 simply hides the old price and displays the right one according to the user selection (when he chooses a specific declination/simple product from the available options). @rossmc

This issue still presents in 2.3. It just doesn't make sense to me to hide the old price on a special price, then who knows the products are on special?? That is wrong in so many ways!

Was this page helpful?
0 / 5 - 0 ratings