{% extends "shop/_layouts/main" %} {% block main %}
| Product | Qty | Price |
|---|
You have no items in your cart, add some on the products page.
{% endif %} {% js %} var states = {{ craft.commerce.states.allStatesAsList|json_encode|raw }}; {% endjs %} {% js %} var $estimateShippingMethodsContainer = $('.estimate-shipping-methods'); var $estimateFieldsContainer = $('.estimate-fields'); var $estimateShowFieldsButton = $('.estimate-show-fields'); var $estimateBilling = $('.estimate-billing'); var $estimateBillingSameAsShipping = $('input[name="estimatedBillingAddressSameAsShipping"]'); var $estimateCountrySelects = $('select.estimate-country'); // Setup "same as" checkbox if ($estimateBillingSameAsShipping.prop('checked')) { $estimateBilling.addClass('hidden').find('input,select').attr('disabled', 'disabled').prop('disabled', 'disabled'); } // Handle the change event for the "same as" checkbox $estimateBillingSameAsShipping.change(function(ev) { var $this = $(this); if ($this.prop('checked')) { $estimateBilling.addClass('hidden').find('input,select').attr('disabled', 'disabled').prop('disabled', 'disabled'); } else { $estimateBilling.removeClass('hidden').find('input,select').attr('disabled', '').prop('disabled', ''); } }); // Setup initial state Showing/hiding of the shipping method selection if ($estimateShippingMethodsContainer.find('.shipping-select').length) { $estimateFieldsContainer.addClass('hidden'); $estimateFieldsContainer.find('input,select').attr('disabled', 'disabled').prop('disabled', 'disabled'); } else { $estimateShippingMethodsContainer.addClass('hidden'); $estimateShippingMethodsContainer.find('input,select').attr('disabled', 'disabled').prop('disabled', 'disabled');; } // Handle click event for returning to the estimate fields $estimateShowFieldsButton.click(function(ev) { ev.preventDefault(); if ($estimateFieldsContainer.hasClass('hidden')) { $estimateFieldsContainer.removeClass('hidden'); $estimateFieldsContainer.find('input,select').attr('disabled', '').prop('disabled', ''); $estimateShippingMethodsContainer.addClass('hidden'); $estimateShippingMethodsContainer.find('input,select').attr('disabled', 'disabled').prop('disabled', 'disabled'); } else { $estimateFieldsContainer.addClass('hidden'); $estimateFieldsContainer.find('input,select').attr('disabled', 'disabled').prop('disabled', 'disabled'); $estimateShippingMethodsContainer.removeClass('hidden'); $estimateShippingMethodsContainer.find('input,select').attr('disabled', '').prop('disabled', ''); } }); // Handle change event for country selection for both shipping and billing $estimateCountrySelects.change(function () { // get the value of the selected country. var cid = $(this).val(); var $box = $('.estimate-state-box[data-modelname="'+$(this).data('modelname')+'"]'); var $states = $box.find('select.address-stateId'); var $stateName = $box.find('input.address-stateName'); $states.find('option').remove(); if (states.hasOwnProperty(cid)) { // We have states for this country, show the states drop down. $states.removeClass('hidden'); $states.attr('name', $states.data('modelname')+'[stateValue]'); // We have states for this country, hide the stateName input. $stateName.removeAttr('name'); $stateName.addClass('hidden'); $stateName.val(''); // Add all states as options to drop down. for (var id in states[cid]) { var state = states[cid][id]; var $option = $(''); $option.attr('value', id).text(state); $states.append($option); } }else{ // hide the states dropdown, since this country has none. $states.addClass('hidden'); $states.removeAttr('name'); // show the stateName $stateName.removeClass('hidden'); $stateName.attr('name', $stateName.data('modelname')+'[stateValue]'); } }); {% endjs %} {% endblock %}