Javascript Apps Information
A Javascript App is a kind of [Jumpseller App](/support/apps/) that can insert javascript on the front-end of a store. This functionality is useful...
Use Javascript Responsibly: Other apps and theme elements may contain Javascript code that might interfere with yours. If you are not sure about the effects of this code contact a professional.
This code show how to hide any of the fields of the Checkout page in your Jumpseller store. Past it on your admin panel: Themes > Code Editor > Payments > Checkout block. Other parts of your store such as the review order, success and customer pages, also emails will show the autocompleted values.
/* Fields that can be marked as optional in Settings > Checkout */ | |
function justHide(field){ | |
$("#shipping_address_" + field).hide(); | |
} | |
$(document).ready(function(){ | |
// Postal Code | |
justHide("postal"); | |
// Municipality | |
justHide("municipality"); | |
}); | |
/* Mandatory fields that require simple autocomplete and hide */ | |
function autoHide(field){ | |
$("#order_shipping_address_" + field).val("Autocompleted " + field); | |
$("#shipping_address_" + field).hide(); | |
} | |
$(document).ready(function(){ | |
// Name | |
autoHide("name"); | |
// Surname | |
autoHide("surname"); | |
// Full Street Address | |
autoHide("address"); | |
// City | |
autoHide("city"); | |
}); | |
/* Special Cases: Country and Regions need to wait for the list to load before autocompleting */ | |
// Selects and hides the Country | |
country_selected = false | |
function selectHideCountry(){ | |
$("#shipping_address_country").hide() | |
var interval_c = setInterval(function(){ | |
if($("#order_shipping_address_country").val() == ""){ | |
$("#order_shipping_address_country option:last").attr("selected", "selected"); | |
var sortBySelect = document.querySelector("#order_shipping_address_country"); | |
sortBySelect.dispatchEvent(new Event("change")); | |
}else{ | |
clearInterval(interval_c) | |
country_selected = true | |
} | |
},500); | |
} | |
// Selects and hides the Region | |
region_selected = false | |
function selectHideRegion(){ | |
var interval_r = setInterval(function(){ | |
if($("#order_shipping_address_region").val() == "" && country_selected ){ | |
$("#order_shipping_address_region option:last").attr("selected", "selected"); | |
}else{ | |
clearInterval(interval_r) | |
region_selected = true | |
$("#shipping_address_region").hide() | |
} | |
},500); | |
} | |
$(document).ready(function(){ | |
selectHideCountry() | |
selectHideRegion() | |
}); |
gistMarkdown.js
Free trial for 14 days. No credit card required.