Disable Shipping Options on Region Select
Create a Javascript code that disables Shipping Methods depending on the selected Region
The Jumpseller Javascript library is included by default into every theme on every store. If you are not confident about what this is about get an overview on Design for Jumpseller. Using this library involves a solid understanding of Javascript.
If you are not a web-designer consider hiring a recommend expert.
isDefined: function(param)param is the name of the variable/method to be checked.requiredAttributesChecker: function(selectors, options)options object has a callback key defined and if selectors is a valid jQuery selector string that only includes valid DOM objects with the change event (select & radio).selectors is the jQuery selectors string.options is the Javascript object.depends on requiredAttributesChecker
paymentMethodListener: function(paymentMethodSelector, options)paymentMethodSelector is a jQuery selector string.options is the Javascript object.depends on requiredAttributesChecker & isDefined
countryListener: function(countriesSelector, options)countriesSelector is a jQuery selector string.options is the Javascript object.calls the callback method defined in the options object. If it fails, returns the Boolean value false.
options.updateRegions is a Boolean value which defaults to false. Otherwise, it will signal the platform to update the Regions’ <select> HTML element. The method will call and depend on getRegions.options.regionsSelector is a String value which defaults to countriesSelector.replace(‘_country’,’_region’);. Otherwise, it should be a string referring to the Regions’ <select> HTML element.depends on requiredAttributesChecker & isDefined
regionListener: function(regionsSelector, options)regionsSelector is a jQuery selector string.options is the Javascript object.calls the callback method defined in the options object. If it fails, returns the Boolean value false.
options.updateComunas is a Boolean value which defaults to false. Otherwise, it will signal the platform to update the Comunas’ <select> HTML element. The method will call and depend on getComunas.options.ComunasSelector is a String value which defaults to regionsSelector.replace(‘_region’,’_comuna’);. Otherwise, it should be a string referring to the Comunas’ <select> HTML element.Example:
<script type="text/javascript">
var callbackFunction = function(){ console.log('region changed'); };
Jumpseller.regionListener("#order_billing_address_region", {callback: callbackFunction()});
</script>
depends on requiredAttributesChecker & updateProductInfo
productVariantListener: function(variantSelectors, options)variantSelectors is a jQuery selector string.options is the Javascript object.getRegions: function(regionSelectID, countryCode, selectedRegion, lat, lng, options)regionSelectID is a jQuery selector string.countryCode is the 2-letter ISO code for the selected Country.selectedRegion is the code for the selected Region.lat is the latitude of the regionlng is the longitude of the regionoptions is the optional parameter. It is an object where callback can be defined like options.callback, where callback is a function in which we can define our code.<select> HTML element will be hidden if no item is returned in the AJAX call.Example:
<script type="text/javascript">
const options = {};
options.callback = function(){
console.log("CALLBACK CALLBACK CALLBACK Regions....")
}
Jumpseller.getRegions("#order_shipping_address_region","CL","05","","",options); // with callback
Jumpseller.getRegions("#order_shipping_address_region","CL","05","",""); // without callback
</script>
getMunicipalities: function(comunaSelectID, regionCode, countryCode, selectedComuna, options)comunaSelectID is a jQuery selector string.regionCode is the code for the selected Region.countryCode is the code for the country for which we want municipalities.selectedComuna is the code for the selected Comuna.options is the optional parameter. It is an object where callback can be defined like options.callback, where callback is a function in which we can define our code.<select> HTML element will be hidden if no item is returned in the AJAX call.Example:
<script type="text/javascript">
const options = {};
options.callback = function(){
console.log("CALLBACK CALLBACK CALLBACK MUNICIPALITY....")
}
Jumpseller.getMunicipalities("#order_shipping_address_municipality","05","CL","8261213", options); // with callback
Jumpseller.getMunicipalities("#order_shipping_address_municipality","05","CL","8261213"); // without callback
</script>
depends on isDefined
updateProductInfo: function(event, variantSelectors, options)event the HTML element event, will be passed as an argument to the callback method.variantSelectors is a jQuery selector string.options is the Javascript object.options.product is the JSON data for the current productsetCurrency function(currency)currency is the 3-letter ISO code for the desired Currencydepends on isDefined
multiCurrency function(options)options is a Javascript object.options.token Open Exchange Rates API token, required to use multi Currency in a Jumpseller storelocalStorage for every user, and renewed every 24h.getCart function(options)options is a Javascript object. Calls the callback method defined in the options object.To get the cart’s total amount:
<script type="text/javascript">
var callbackFunction = function(data){ console.log(data.total); }; // outputs the cart's total amount.
Jumpseller.getCart({callback: callbackFunction})
</script>
updateCart function(order_product_id, qty, options)options is a Javascript object. Calls the callback method defined in the options object.Example:
<script type="text/javascript">
var callbackFunction = function(){ console.log('cart updated'); };
Jumpseller.updateCart(12345, 1, {callback: callbackFunction()});
</script>
clearCart function(options)options is a Javascript object. Calls the callback method defined in the options object.Example:
<script type="text/javascript">
var callbackFunction = function(){ console.log('cart cleared'); };
Jumpseller.clearCart({callback: callbackFunction()});
</script>
addProductToCart function(product_id, qty, product_options, options)options is a Javascript object. Calls the callback method defined in the options object.To add a product with the ID 12345 to the cart use:
Jumpseller.addProductToCart(12345, 1, { }, {callback: callbackFunction})
If the product has variants, the option IDs and the product option value IDs need to be passed:
Jumpseller.addProductToCart(12345, 1, { 555: 123123, 777: 321321, 999: 3213214 }, {callback: callbackFunction})
If is a product option of Type text or input the text is passed on the value field:
Jumpseller.addProductToCart(12345, 1, { 123: 'Example Text' }, {callback: callbackFunction})
To represent a callback function use:
<script type="text/javascript">
var callbackFunction = function(data){
console.log(data);
};
</script>
addMultipleProductsToCart function(products, options)[[prod_1_id, prod_1_qty, prod_1_product_options], [prod_2_id, prod_2_qty, prod_2_product_options]]
options is a Javascript object. Calls the callback method defined in the options object.To add the products with the IDs 12345 and 54321 to the cart use:
Jumpseller.addMultipleProductsToCart([[12345, 1, { }], [54321, 1, { }]], {callback: callbackFunction})
If the product 12345 has variants, the option IDs and the product option value IDs need to be passed:
Jumpseller.addMultipleProductsToCart([[12345, 1, { 555: 123123, 777: 321321, 999: 3213214 }], [54321, 1, { }]], {callback: callbackFunction})
addCouponToCart function(codes, options)options is a Javascript object. Calls the callback method defined in the options object.Example:
Jumpseller.addCouponToCart("test-coupon", {callback: callbackFunction})
Jumpseller.addCouponToCart(["test-coupon", "test-coupon-1", "test-coupon-2"], {callback: callbackFunction})
removeCouponFromCart function(code, options)options is a Javascript object. Calls the callback method defined in the options object.Example:
Jumpseller.removeCouponFromCart("test-coupon", {callback: callbackFunction})
Jumpseller.removeCouponFromCart(["test-coupon", "test-coupon-1", "test-coupon-2"], {callback: callbackFunction})
getCurrentProductInfo function(options)options is a Javascript object. Calls the callback method defined in the options object.Example:
<script type="text/javascript">
var callbackFunction = function(data){ console.log(data); }; // outputs the product's available data
Jumpseller.getCurrentProductInfo({callback: callbackFunction})
</script>
getCurrentCategoryInfo function(options)options is a Javascript object. Calls the callback method defined in the options object.Example:
<script type="text/javascript">
var callbackFunction = function(data){ console.log(data); }; // outputs the category's available data
Jumpseller.getCurrentCategoryInfo({callback: callbackFunction})
</script>
getCurrentSearchInfo function(options)options is a Javascript object. Calls the callback method defined in the options object.Example:
<script type="text/javascript">
var callbackFunction = function(data){ console.log(data); }; // outputs the search query result data
Jumpseller.getCurrentSearchInfo({callback: callbackFunction})
</script>
Start your free 7-day trial. No credit card required.