2

Is there anyway even if there 0 discount but it should always be visible?

1 Answer 1

1

There are two ways to display discount even if it's 0

Method 1: Override discount.js file:

Override isDisplayed() function from vendor/magento/module-sales-rule/view/frontend/web/js/view/cart/totals/discount.js

app/design/frontend/Magento_SalesRule/web/js/view/cart/totals/discount.js

Change from

isDisplayed: function () {
    return this.getPureValue() != 0; //eslint-disable-line eqeqeq
}

To

isDisplayed: function () {
    return true;
}

Method 2: Override discount.html

Override `vendor/magento/module-sales-rule/view/frontend/web/template/cart/totals/discount.html

app/design/frontend/Magento_SalesRule/web/template/cart/totals/discount.html

Remove knockout condition

<!-- ko if: isDisplayed() -->
<!-- /ko -->

Final discount.html

<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<tr class="totals">
    <th colspan="1" style="" class="mark" scope="row">
        <span class="title" data-bind="text: getTitle()"></span>
        <span class="discount coupon" data-bind="text: getCouponLabel()"></span>
    </th>
    <td class="amount" data-bind="attr: {'data-th': title}">
        <span><span class="price" data-bind="text: getValue()"></span></span>
    </td>
</tr>
5
  • Thanks for the instant reply but it didn't work for me... Commented Jun 25, 2018 at 9:45
  • This must be work. Please check any third party module which override discount file. Commented Jun 25, 2018 at 10:17
  • Hi it's showing on cart page but not in checkout? Do u have any idea to make it even visible on Checkout page? Commented Jul 5, 2018 at 9:05
  • I am using Magento 2.1.16 and thid did not work for me.
    – Abid Malik
    Commented May 27, 2019 at 19:03
  • @PrincePatel i have apply same code in checkout summery and rule is working but coupon title is mising prntscr.com/pkf4vw i want to when apply my coupon code and showing title also discount price 0 not always Commented Oct 17, 2019 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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