2

The cart price rule "Default Rule Label" and "Store View Specific Labels" are not displayed in the cart. (see screenshot) However the labels are nicely displayed in the confirmation email and on the invoice.

Youd should expect the description displayed between brackets after Discount (where you see now as an example in red 'no label'

I have search an hour on the internet, but I couldn’t find a proper fix or solution. Anybody an idea how to solve this?

enter image description here

Thanks

2 Answers 2

2

For display the Discount Description in cart page you need to override the Magento_SalesRule module js file and html template in your theme

Step 1: First Create Magento_SalesRule folder in your theme

Step 2: override the vendor/magento/module-sales-rule/view/frontend/web/js/view/summary/discount.js file in theme your-package/your-theme/Magento_SalesRule/web/js/view/summary/discount.js and put below code in this file

/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
/*global define*/
define(
    [
        'Magento_Checkout/js/view/summary/abstract-total',
        'Magento_Checkout/js/model/quote',
        'Magento_Checkout/js/model/totals'
    ],
    function (Component, quote,total) {
        "use strict";
        return Component.extend({
            defaults: {
                template: 'Magento_SalesRule/summary/discount'
            },
            totals: quote.getTotals(),
            isDisplayed: function() {
                return this.isFullMode() && this.getPureValue() != 0;
            },
            getTitle: function() {
                var title=total.getSegment('discount');

                if (!this.totals()) {
                    return null;
                }
                return title.title;
            },
            getCouponCode: function() {

                if (!this.totals()) {
                    return null;
                }
                return this.totals()['coupon_code'];
            },
            getPureValue: function() {
                var price = 0;
                if (this.totals() && this.totals().discount_amount) {
                    price = parseFloat(this.totals().discount_amount);
                }
                return price;
            },
            getValue: function() {
                return this.getFormattedPrice(this.getPureValue());
            }
        });
    }
);

Step 3: For display Discount Description in cart override the vendor/magento/module-sales-rule/view/frontend/web/template/cart/totals/discount.html file in theme your-package/your-theme/Magento_SalesRule/web/template/cart/totals/discount.html and put below code

<!-- ko if: isDisplayed() -->
<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: getCouponCode()"></span>
    </th>
    <td class="amount" data-bind="attr: {'data-th': title}">
        <span><span class="price" data-bind="text: getValue()"></span></span>
    </td>
</tr>
<!-- /ko -->

Step 4: For display Discount Description in checkout override the vendor/magento/module-sales-rule/view/frontend/web/template/summary/discount.html file in theme your-package/your-theme/Magento_SalesRule/web/template/summary/discount.html and put below code

<!-- ko if: isDisplayed() -->
<tr class="totals discount">
    <th class="mark" scope="row">
        <span class="title" data-bind="text: getTitle()"></span>
        <span class="discount coupon" data-bind="text: getCouponCode()"></span>
    </th>
    <td class="amount">
        <span class="price" data-bind="text: getValue(), attr: {'data-th': name}"></span>
    </td>
</tr>
<!-- /ko -->
2

Answer #1 is no longer necessary. This has been addressed apparently by vanilla Magento, probably part of the Magento 2 upgrade.

Just specify a Default Rule Label under the Labels section and that text will show when the automatic cart rule is applied!

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.