3

I am working on a Magento 2.1.7 shop.

On my category pages, I need to disable "As low as" price, as it ruins the products grid.

enter image description here

I want to hide it on configurable and non-configurable products, but only on the category pages. If possible, not with CSS (display: none).

What is the easiest and/or the most appropriate way to do this?

  • do you want to show for configurable product? – Sunil Patel Jan 8 '18 at 11:52
  • I would prefer to hide it on any kind of product, but only on the category page. – Razvan Zamfir Jan 8 '18 at 11:54
  • magento 2 default showing only for bundle, is your product is bundle product? – Sunil Patel Jan 8 '18 at 11:55
  • I have added details to the question. – Razvan Zamfir Jan 8 '18 at 11:58
3

I have solved it with a piece of less/css:

.product-items .minimal-price-link {
  display: none;
}
| improve this answer | |
0

check below code:-

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>

<?php
$idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
/** @var \Magento\Bundle\Pricing\Render\FinalPriceBox $block */

/** @var \Magento\Bundle\Pricing\Price\FinalPrice $finalPriceModel */
$finalPriceModel = $block->getPrice();
$minimalPrice = $finalPriceModel->getMinimalPrice();
$maximalPrice = $finalPriceModel->getMaximalPrice();
/** ex: \Magento\Bundle\Pricing\Price\BundleRegularPrice */
/** @var \Magento\Framework\Pricing\Price\PriceInterface $regularPriceModel */
$regularPriceModel = $block->getPriceType('regular_price');
$maximalRegularPrice = $regularPriceModel->getMaximalPrice();
$minimalRegularPrice = $regularPriceModel->getMinimalPrice();
?>


<?php if ($block->getSaleableItem()->getPriceView()): ?>
    <p class="minimal-price">
        <?php /* @escapeNotVerified */ echo $block->renderAmount($minimalPrice, [
            'display_label'     => __('As low as'),
            'price_id'          => $block->getPriceId('from-'),
            'include_container' => true
        ]); ?>
        <?php if ($minimalPrice < $minimalRegularPrice): ?>
            <span class="old-price">
                <?php /* @escapeNotVerified */ echo $block->renderAmount($minimalRegularPrice, [
                    'display_label'     => __('Regular Price'),
                    'price_id'          => $block->getPriceId('old-price-' . $idSuffix),
                    'include_container' => true,
                    'skip_adjustments'  => true
                ]); ?>
            </span>
        <?php endif ?>
    </p>
<?php else: ?>
    <?php if ($block->showRangePrice() && !$block->isProductList()): ?>
        <p class="price-from">
            <?php /* @escapeNotVerified */ echo $block->renderAmount($minimalPrice, [
                'display_label'     => __('From'),
                'price_id'          => $block->getPriceId('from-'),
                'price_type'        => 'minPrice',
                'include_container' => true
            ]); ?>
            <?php if ($minimalPrice < $minimalRegularPrice): ?>
                <span class="old-price">
                    <?php /* @escapeNotVerified */ echo $block->renderAmount($minimalRegularPrice, [
                        'display_label'     => __('Regular Price'),
                        'price_id'          => $block->getPriceId('old-price-' . $idSuffix),
                        'include_container' => true,
                        'skip_adjustments'  => true
                    ]); ?>
                </span>
            <?php endif ?>
        </p>
        <p class="price-to">
            <?php /* @escapeNotVerified */ echo $block->renderAmount($maximalPrice, [
                'display_label'     => __('To'),
                'price_id'          => $block->getPriceId('to-'),
                'price_type'        => 'maxPrice',
                'include_container' => true
            ]); ?>
            <?php if ($maximalPrice < $maximalRegularPrice): ?>
                <span class="old-price">
                    <?php /* @escapeNotVerified */ echo $block->renderAmount($maximalRegularPrice, [
                        'display_label'     => __('Regular Price'),
                        'price_id'          => $block->getPriceId('old-price-' . $idSuffix),
                        'include_container' => true,
                        'skip_adjustments'  => true
                    ]); ?>
                </span>
            <?php endif ?>
        </p>
    <?php else: ?>
        <?php /* @escapeNotVerified */ echo $block->renderAmount($minimalPrice, [
            'price_id'          => $block->getPriceId('product-price-'),
            'include_container' => true
        ]); ?>
        <?php if ($minimalPrice < $minimalRegularPrice): ?>
            <span class="old-price">
                <?php /* @escapeNotVerified */ echo $block->renderAmount($minimalRegularPrice, [
                    'display_label'     => __('Regular Price'),
                    'price_id'          => $block->getPriceId('old-price-' . $idSuffix),
                    'include_container' => true,
                    'skip_adjustments'  => true
                ]); ?>
            </span>
        <?php endif ?>
    <?php endif ?>
<?php endif ?>
| improve this answer | |
  • Your code shows <?php if ($block->getSaleableItem()->getPriceView()): ?> twice. I only have it once. – Razvan Zamfir Jan 8 '18 at 12:26
  • I'm afraid It does not work. – Razvan Zamfir Jan 8 '18 at 12:36
  • is there showing any error – Sunil Patel Jan 8 '18 at 12:36
  • No, so maybe this is wrong: $block->isProductList()... – Razvan Zamfir Jan 8 '18 at 12:48
  • There is an 11 before the first if statement. – Razvan Zamfir Jan 8 '18 at 13:31

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.