Skip to content

Instantly share code, notes, and snippets.

@aatronco
aatronco / validaterut
Last active May 26, 2017 21:02
Validate format and verification digit of Chile tax ID (RUT)
<script type="text/javascript">
$(document).ready(function(){
$("#order_shipping_address_taxid").attr("pattern", "[0-9]{7,8}-[0-9Kk]{1}"); // with . and . [0-9]{1,2}.[0-9]{3}.[0-9]{3}-[0-9Kk]{1}
$("#order_shipping_address_taxid").attr("placeholder", "ej. 12345678-5");
$("#order_shipping_address_taxid").attr("title", "ej. 12345678-5");
var Fn = {
// Valida el rut con su cadena completa "XXXXXXXX-X"
validaRut : function (rutCompleto) {
if (!/^[0-9]+[-|‐]{1}[0-9kK]{1}$/.test( rutCompleto ))
@aatronco
aatronco / variant_price.liquid
Created July 20, 2017 16:12
Gets variant price searching for a variant value name
{% for variant in product.variants %}
{% for value in variant.values %}
{% if value.name == "Por Mayor" %}
{% assign precio_por_mayor = variant.price %}
{%endif%}
{%endfor%}
{%endfor%}
{{precio_por_mayor | price}}
var shipping_to = ["Ñuñoa","Providencia","Vitacura","Santiago Centro","Las Condes"]; //hides all states not included in this array
var interval = setInterval(function(){
if($('#order_shipping_address_municipality').text()){
$('#order_shipping_address_municipality option:not(:first)').filter(function() {
return $.inArray($.trim($(this).text()), shipping_to) == -1;
}).remove();
clearInterval(interval)
}
<script type="text/javascript">
$(document).ready(function(){
$('form#checkout').submit(function(){
// change address to "retiro en tienda"
if($('#order_shipping_method_96203').is(':checked')){
$('#order_shipping_address_address').val('Av. Apoquindo 4900 local 160, Centro Comercial OMNIUM');
$('#order_shipping_address_city').val('Santiago');
$('#order_shipping_address_postal').val('7560973');
$('#order_shipping_address_region').val('12')
<script type="text/javascript">
var shipping_to = ["12","03"]; //hides all regiones not included in this array
setTimeout(function(){
$('#estimate_shipping_region option').filter(function() {
return $.inArray($.trim($(this).val()), shipping_to) == -1;
}).remove();
}, 1000);
$("#estimate_shipping_region").change();
</script>
<script type="text/javascript">
// In admin panel: Settings > Checkout should be like: https://www.evernote.com/l/AJqFD-JxfUtEoI5LVNy_tRocu30aPTBBVuk
// Boleta o Factura Should be like: https://www.evernote.com/l/AJpcG43vJa1GLbQi2OgbRN_T4iUvJcIS4VQ
$(document).ready(function(){
setTimeout(function(){ $("#other").prependTo("#shipping_address_same_as_shipping"); $("#order_billing_address_country").val('CL'); $("#order_billing_address_country").change(); }, 1000); // set billing address for chile.
var Fn = {
<script>
// Municipalities and region codes are here: https://docs.google.com/spreadsheets/d/1X4A4gBMHehHSFWVDF1e17XPOc6dY4f6byqkl7MM7ENo/edit?usp=sharing
$("#order_shipping_address_region").change(function(){
if( $('#order_shipping_method_100969').is(':checked')){ // cambiar el numero 100969 por el codigo del medio de envio de retiro en tienda se obtiene acá http://prntscr.com/lf7v08
var interval = setInterval(function(){
$('#order_shipping_address_municipality').val(8261417); // cambiar código de comuna por el que corresponda
if($('#order_shipping_address_municipality').val()){
$('#order_shipping_address_municipality').parent().hide();
<script>
$(document).ready(function(){
$("#payments_options ul").append('<li><input class="default_radio" type="radio" checked="checked" name="order[payment_method]" value="" class="radiobox" hidden></li>');
$("#shipping_options ul").append('<li><input class="default_radio" type="radio" checked="checked" name="order[shipping_method]" value="" class="radiobox" hidden></li>');
});
$("#checkout").submit(function(evt){
if( $("#payments_options input:checked").val() == "" || $("#shipping_options input:checked").val() == "" ){
evt.preventDefault();
alert({% t "Select Payment and Sipping Methods" %} );
<script>
$('form#product-form select').each(function(i, select){ // product-form is the ID of my form, may change on your theme, verify in the design template of the products
var $select = $(select);
$select.find('option').each(function(j, option){
var $option = $(option);
// Create a radio:
var $radio = $('<input type="radio" />');
// Set name and value:
$radio.attr('name', $select.attr('name')).attr('value', $option.val());
// Set checked if the option was selected
@aatronco
aatronco / rut.liquid
Last active March 26, 2020 15:27
Validate RUT in Jumpseller Checkout // Validación de RUT // insertar estos dos JS en el checkout
<script>
(function($) {
jQuery.fn.Rut = function(options) {
var defaults = {
digito_verificador: null,
on_error: function() {},
on_success: function() {},
validation: true,
format: true,
format_on: 'change'