0

In order summary (Cart page), Shipping Method is displayed as:

(Method Name - Method Title)

Is it possible to remove Method Title and display just the Name?

enter image description here

1
  • yeah just override the summary template
    – fmsthird
    Mar 29, 2019 at 15:22

2 Answers 2

6

Please override your file

vendor/magento/module-checkout/view/frontend/web/js/view/summary/shipping.js

to

/app/design/frontend/Vendor/ThemeName/Magento_Checkout/web/js/view/summary/shipping.js

Change Below Function Your Theme

 getShippingMethodTitle: function () {
        var shippingMethod,
            shippingMethodTitle = '';

        if (!this.isCalculated()) {
            return '';
        }
        shippingMethod = quote.shippingMethod();

        if (typeof shippingMethod['method_title'] !== 'undefined') {
            shippingMethodTitle = shippingMethod['method_title'];
        }

        return shippingMethod ? shippingMethodTitle : '';
    },
1
  • this overriding in checkout summary as well.
    – Ramya
    Feb 28, 2020 at 11:20
2

The above answer detailed by Mohit will work fine, although instead of over-riding the shipping.js file, best to add the changes as a Mixin.

If you aren't familiar with Mixins, best to read up about it in Magento's documentation: https://devdocs.magento.com/guides/v2.4/javascript-dev-guide/javascript/js_mixins.html

Create the following file: app/design/frontend/VendorName/ThemeName/Magento_Checkout/requirejs-config.js

var config = {
    config: {
        mixins: {
            'Magento_Checkout/js/view/summary/shipping': {
                'Magento_Checkout/js/view/summary/shipping-mixin': true
            },
        }
    }
};

Then create the Mixin file. Best practise to keep the path the same as the file you are extending, and then adding -mixin to the end.

app/design/frontend/VendorName/ThemeName/Magento_Checkout/web/js/view/summary/shipping-mixin.js

define([
    'jquery',
    'underscore',
    'Magento_Checkout/js/view/summary/abstract-total',
    'Magento_Checkout/js/model/quote',
    'Magento_SalesRule/js/view/summary/discount'
], function ($, _, Component, quote, discountView) {
    'use strict';

    var mixin = {

        /**
         * @return {*}
         */
        getShippingMethodTitle: function () {

            var shippingMethod,
                shippingMethodTitle = '';

            if (!this.isCalculated()) {
                return '';
            }
            shippingMethod = quote.shippingMethod();

            if (!_.isArray(shippingMethod) && !_.isObject(shippingMethod)) {
                return '';
            }

            if (typeof shippingMethod['method_title'] !== 'undefined') {
                shippingMethodTitle = shippingMethod['method_title'];
            }

            return shippingMethodTitle ?
                shippingMethodTitle : '';
        },

    };

    return function (target) {
        return target.extend(mixin);
    };
});

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.