I want to add active class When I select a shipping method on the checkout page.
For example: If I select free shipping then active class should be added on radio button which is free shipping.
Thanks in advance.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityYou can add below JS code in your checkout page for your requirement.
<script>
require([
'jquery'
], function ($) {
$(document).ready(function () {
$("body").on("click", "#checkout-shipping-method-load .col-method .radio", function(){
$("#checkout-shipping-method-load .col-method .radio").removeClass("active");
if($(this).attr("checked") == "checked") {
$(this).addClass("active");
}
});
});
});
</script>
Flush the cache after the changes.
Hope it helps!!!