0

I need to hide $0.00 & replace by text 'Free Shipping' on checkout page if shipping method is free shipping

enter image description here

2
  • Have you tried hiding it with css? – SantiBM Jun 6 '19 at 6:48
  • I updated my question I think hiding with css will not work as i need to replace it by 'Free shipping' – Arjun Jun 6 '19 at 6:54
1

Override core price.js for shipping method into your theme.

path : /vendor/magento/module-tax/view/frontend/web/js/view/checkout/shipping_method/price.js

Replace below code :

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

/**
 * @api
 */

define([
    'uiComponent',
    'Magento_Checkout/js/model/quote',
    'Magento_Catalog/js/price-utils'
], function (Component, quote, priceUtils) {
    'use strict';

    return Component.extend({
        defaults: {
            template: 'Magento_Tax/checkout/shipping_method/price'
        },
        isDisplayShippingPriceExclTax: window.checkoutConfig.isDisplayShippingPriceExclTax,
        isDisplayShippingBothPrices: window.checkoutConfig.isDisplayShippingBothPrices,

        /**
         * @param {Object} item
         * @return {Boolean}
         */
        isPriceEqual: function (item) {
            return item['price_excl_tax'] != item['price_incl_tax']; //eslint-disable-line eqeqeq
        },

        /**
         * @param {*} price
         * @return {*|String}
         */
        getFormattedPrice: function (price) {
            //todo add format data
            if (price === 0) {
                return "Free Shipping";
            }
            return priceUtils.formatPrice(price, quote.getPriceFormat());
        }
    });
});
2
  • This is working only change the file path (/vendor/magento/module-tax/view/frontend/web/js/view/checkout/shipping_method/price.js) – Arjun Jun 6 '19 at 8:50
  • 1 more thing how can I hide free Shipping title which is shown by shipping method – Arjun Jun 6 '19 at 9:59

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.