Created
February 22, 2022 15:44
-
-
Save be-mohand/ac3f41f3c5ad24c7f97e65022b136a7a to your computer and use it in GitHub Desktop.
Use this JavaScript snippet to make sure at least one shipping method is selected if shipping is enabled when we use the AddOns as shipping selector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Making sure at least one shipping method is selected if shipping is enabled | |
*/ | |
if(typeof Kr !== 'undefined' && typeof Kr.Listing !== 'undefined' && Kr.Listing !== null && document.querySelectorAll('input[name="addons"]').length > 0) | |
{ | |
let checkIfShippingHasBeenSelected = function() { | |
if(document.querySelectorAll('input[name="addons"]:checked').length === 0) { | |
[].forEach.call(document.querySelectorAll('input[name="addons"]:first-child'), function (el) {el.checked = true}); | |
} | |
} | |
checkIfShippingHasBeenSelected(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment