Alejandro Troncoso
2021-05-03T20:03:01Z

hide_show_shipping_method.liquid

|
| const shipping_method_id = 1234556 // id of free shipping option
| const normal_shipping = 654321 // id of normal shipping option
| const municipalities_free_shipping = ["merchant needs to complete this field"] // Ideally a theme option separated by comma
| const products_free_shipping = ["merchant needs to complete this field"] // Ideally a theme option separated by comma
|
| var conditions = function() {
| // certain product is in the cart and certain municipalities are selected. The work is to construct this function
| }
|
| var special_shipping = function() {
| if (conditions()) {
| $('#shipping_options input[value=' + shipping_method_id + ']').parent().show();
| } else {
| $('#shipping_options input[value=' + shipping_method_id + ']').parent().hide();
| $('#shipping_options input[value=' + normal_shipping + ']').click();
| }
| }
|
| // Execute the function
| $(document).ready(special_shipping);
| $(checkout).change(special_shipping);
|