Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Paste this on the Checkout Block. Change the regions and shipping options.
var regions = ["Metropolitana"] // List Regions with disabled shipping Methods
var shipping_options = ["14906-service"] // List shipping Option Code Values (These can be found on the URL of the Shipping option)
// Don't change anything below
function regionIsSelected() {
return $.inArray($.trim($("#order_shipping_address_region option:selected").text()), regions) > -1;
};
function disable_shipping(val, index, array) {
$("input[value=" + val + "]").prop('checked',false);
};
function enable_shipping(val, index, array) {
$("input[value=" + val + "]").prop('checked',true);
};
function shippingController() {
console.log("Region Selected: " + regionIsSelected())
if (regionIsSelected()) {
shipping_options.forEach(enable_shipping);
} else {
shipping_options.forEach(disable_shipping); }
}
$(document).ready(shippingController)
$("#order_shipping_address_region").change(shippingController);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.