Alejandro Troncoso
2019-10-07T10:12:48Z

Disable Shipping Options based on Region.liquid

|
| // Define the shipping method for the local region (metropolitana) and for all others.
| let metropolitana = 267131
| let others = "22276-service"
|
| // Function verifies if customer selected the local region (Metropolitana).
| function metropolitanaIsSelected() {
| return $.inArray($.trim($("#order_shipping_address_region option:selected").text()), ["Metropolitana"]) > -1;
| };
| // Function to hide/show the correct local method.
|
| var shippingController = function() {
| if (metropolitanaIsSelected()) {
| $("input[value=" + metropolitana + "]").parent().show()
| } else {
| $("input[value=" + others + "]").parent().show()
| $("input[value=" + others + "]").click()
| $("input[value=" + metropolitana + "]").parent().hide()
| }
|
| };
| // Applies the funcion on document and region select load and after changing the region.
| $(document).ready(function() {
| Jumpseller.regionListener("#order_shipping_address_region", {
| callback: shippingController
| });
| })
| $("#order_shipping_address_region").change(shippingController);
|