Last active
March 15, 2019 14:21
-
-
Save aatronco/aedd723475cb810ce1cd598e47c75ac8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <script> | |
| var stores = { | |
| CasaMatriz: { | |
| id: "113269", | |
| address: "Retiro en Tienda: Dr. Manuel Barros Borgoño 160, OF 201, Providencia - Retiro a Partir de 1 Dia Habil.", | |
| city: "Santiago", | |
| municipality: 8261414, | |
| region: "12" | |
| }, | |
| LosLeones: { | |
| id: "128276", | |
| address: "Retiro en Tienda: Av. Providencia 2237, Local P-35G, Providencia (Metro Los Leones) - Retiro a Partir de 2 Dias Habiles", | |
| city: "Santiago", | |
| municipality: 8261414, | |
| region: "12" | |
| }, | |
| Meiggs: { | |
| id: "128277", | |
| address: "Retiro en Tienda: Av Salvador Sanfuentes 2737, Local 4, Santiago (Metro U.L.A) - Retiro a Partir de 3 Dias Habiles.", | |
| city: "Santiago", | |
| municipality: 8261400, | |
| region: "12" | |
| } | |
| }; | |
| function selectStore() { | |
| selectedStore = $("#shipping_options input:checked").val(); | |
| $.each(stores, function(index, store) { | |
| if (store.id == selectedStore) { | |
| selectedStore = store | |
| return false; | |
| } | |
| }); | |
| } | |
| selectStore() | |
| function fillAddress(store) { | |
| $("#order_shipping_address_address").val(store.address) | |
| $("#order_shipping_address_address").parent().hide(); | |
| $("#order_shipping_address_city").val(store.city) | |
| $("#order_shipping_address_city").parent().hide(); | |
| var interval_r = setInterval(function(){ | |
| $("#order_shipping_address_region").val(store.region); | |
| if($('#order_shipping_address_region').val()){ | |
| $('#order_shipping_address_region').parent().hide(); | |
| console.log($('#order_shipping_address_region').val()); | |
| // fire native change event on select element -- START | |
| element = document.getElementById('order_shipping_address_region') | |
| var evt = document.createEvent("HTMLEvents"); | |
| evt.initEvent("change", false, true); | |
| element.dispatchEvent(evt); | |
| // fire native change event on select element -- END | |
| clearInterval(interval_r) | |
| } | |
| }, 200) | |
| $("#order_shipping_address_region").change(function(){ | |
| var interval_m = setInterval(function(){ | |
| $("#order_shipping_address_municipality").val(store.municipality); | |
| if($('#order_shipping_address_municipality').val()){ | |
| $('#order_shipping_address_municipality').parent().hide(); | |
| console.log($('#order_shipping_address_municipality').val()) | |
| clearInterval(interval_m) | |
| } | |
| }, 200); | |
| }); | |
| } | |
| $(document).ready(function(){ | |
| selectStore() | |
| fillAddress(selectedStore) | |
| }); | |
| $("#shipping_options input").change(function(){ | |
| selectStore() | |
| fillAddress(selectedStore) | |
| }); | |
| </script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment