0

I successfully managed to add a "is-selected" class on the checkout shipping method row element on click using a mixin like this :

var mixin = {

    /**
     * @param {Object} shippingMethod
     * @return {Boolean}
     */
    selectShippingMethod: function (shippingMethod) {
        $('.table-checkout-shipping-method .row').removeClass('is-selected');
        $(event.currentTarget).addClass('is-selected');

        selectShippingMethodAction(shippingMethod);
        checkoutData.setSelectedShippingRate(shippingMethod['carrier_code'] + '_' + shippingMethod['method_code']);

        return true;
    }
};

return function (target) { // target == Result that Magento_Ui/.../columns returns.
    return target.extend(mixin); // new result that all other modules receive
};

Now I'm looking for add set this class on the default selected shipping method (on page load).

I see that there is a is an isSelected method in this file :

module-checkout/view/frontend/web/js/view/shipping.js 

but I can't find how to get the selected element (to add a class on it).

Any ideas ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.