Skip to content

Instantly share code, notes, and snippets.

<script type="application/javascript">
$(document).ready(function(){
$("#order_shipping_address_city").val("Content");
$("#shipping_address_city").hide();});
</script>
<script type="application/javascript">
$(document).ready(function(){
$("#order_customer_phone").attr("pattern","/^(\+?56)?(\s?)(0?9)(\s?)[9876543]\d{7}$/");
$("#order_customer_phone").attr("placeholder","+569XXXXXXXX");
});
</script>
<script>
$(document).ready(function(){
addRutValidator($('#order_shipping_address_taxid'));
addRutValidatorForBillingAddress($('#order_billing_address_taxid'));
$("#shipping_same_as_billing").on('change', function(evt) {
addRutValidatorForBillingAddress($('#order_billing_address_taxid'));
})
})
function addRutValidatorForBillingAddress(element) {
<script type="application/javascript">
var dte_fields = function() {
if ($("#order_other_boleta_o_factura").val().includes("Boleta")) {
$("#other_giro,#other_razon_social").hide();
$("#other_giro,#other_razon_social").removeAttr("required");
} else {
$("#other_giro,#other_razon_social").show();
$("#other_giro,#other_razon_social").attr("required", "required");
}
}
<script>
var Fn = {
validaRut: function(rutCompleto) {
if (!/^[0-9]+-[0-9kK]{1}$/.test(rutCompleto))
return false;
var tmp = rutCompleto.split('-');
var digv = tmp[1];
var rut = tmp[0];
if (digv == 'K') digv = 'k';
return (Fn.dv(rut) == digv);
<!-- Instructions
Step 1: identify Payment Method IDs:
- Avalpay: 251942
- Bancolombia: 251947
- Contra entrega: 271580
Step 2: Upload logos to the code editor
Step 3: Paste the code on the checkout.
->>
<script>
<!-- creates a custom select on the Contact page -->
<div id="custom_select_container" class="field col-md-12">
<label for="contactpage_name" class="required control-label">Custom Field <em>*</em></label><br>
<select id="custom_select" class="text form-control" required="required" >
<option value=""></option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
<script>
// Variables
var productId = 7576049 // Create virtual product and get the product id
var variant1 = 11996397 // Create a variant of the product, this is the variant that will go to the cart.
// Conditions Function: This function returns true or false depending if the conditions are present or not on the checkout. This part can change depending on the conditions.
var conditions = function(){
return $("#ID_DE_CAJA_DE_VERIFICACION").is(":checked"); // Certain payment option is selected on this example
}
// Finds product_cart_id by searching the productId on the cart. The Product Cart Id is the ID of the instance of the product that is on the cart. This section shouldn't change.
function find_order_product_id(cart_json) {
@aatronco
aatronco / open_variant_from_url_parameter.js
Created March 17, 2021 20:05
Chooses al of the options from a product URL containing the variant_id parameter in Jumpseller
$(document).ready(function() {
// Get the variant_id from the parameter
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
if (urlParams.has('variant_id')) {
const variant_id = urlParams.get('variant_id')
var update_function = function(data) {
// Find the variant
active_variant = data.variants.find(item => item.id == variant_id)
var callbackFunction = function() {
console.log("Coupon " + discount + " added")
}
var add_url_coupon = function() {
queryString = window.location.search;
urlParams = new URLSearchParams(queryString);
if (urlParams.has('discount')) {
discount = urlParams.get('discount')
Jumpseller.addCouponToCart(discount, {