Skip to content

Instantly share code, notes, and snippets.

<script>
var verify_document = function() {
if ($("#order_other_documento_electronico option:selected").val() == "Factura Electronica") {
$("#other_giro").show()
$("#order_other_giro").attr("required", "required")
$("#other_razon_social").show()
$("#order_other_razon_social").attr("required", "required")
} else {
<!-- Requires adaptation to the Theme -->
<div class="post-prev-text align-center">
{% if product.discount > 0 %}
<strong>{% t "From" %} </strong>{{ product.price | minus:product.discount | price }} <del> {{ product.price | price }}</del>
{% else %}
{% assign variant_prices = product.variants | sort: 'price' | map: 'price' %}
{% if variant_prices.size > 1 %}
<strong>{{ variant_prices | first | price }} - {{ variant_prices | last | price }}</strong>
{%else%}
{{product.price | price}}
<div id="alerta" class="alert alert-info" role="alert">
<strong>Heads up!</strong> This alert needs your attention, but it's not super important.
</div>
<script>
var alert_checkout = function(){
if($("#order_shipping_address_region").val() == "01"){
$("#alerta").show()
<script>
// Variables
var productId = 4482829 // Create virtual product and get the product id
var variant1 = 8769517 // 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 $("#payments_options input:checked").val() == "186648"; // Certain payment option is selected on this example
}
<script>
$(document).ready(function(){
const queryString = window.location.search;
var decodedString = decodeURIComponent(queryString)
console.log(decodedString.slice(1));
$("#contact_message").val(decodedString.slice(1));
});
</script>
{% if order.subtotal < 100 %}
<script>
// Add this to your checkout block. Change the minimum from 100 to your desired number. Use a large number to block all purchase, change to 0 to block none
// Design your message
var message = '<i class="fa fa-info-circle fa-fw"></i>There is a minimum order required of <strong>100 USD</strong>'
var alert_m = '<div align="middle" id="alert-minimum" class="text-center alert alert-warning m-0">' + message + '<br><a onclick="history.go(-1); return false;" href="#" class="btn btn-sm btn-secondary mt-2" title="&larr; {% t 'Go back & Keep Shopping' %}">&larr; {% t "Go back & Keep Shopping" %}</a></div>'
$(document).ready(function(){
$("#checkout").before(alert_m)
@aatronco
aatronco / hideCheckout.js
Last active November 7, 2019 17:47
Code to hide/ autocomplete all checkout shipping fields
/* Fields that can be marked as optional in Settings > Checkout */
function justHide(field){
$("#shipping_address_" + field).hide();
}
$(document).ready(function(){
// Postal Code
justHide("postal");
var selectName = "order_other_boleta_o_factura"
function validateFactura(){
if( $("#" + selectName ).val() == "factura" ) {
$("#other_giro,#other_razon_social").show();
$("#order_other_giro,#order_other_razon_social").attr('required','required');
} else {
$("#other_giro,#other_razon_social").hide();
$("#order_other_giro,#order_other_razon_social").removeAttr('required');
}
/* Fields that can be marked as optional in Settings > Checkout */
function justHide(field) {
$("#billing_address_" + field).hide();
}
$(document).ready(function() {
// Postal Code
justHide("postal");
<script>
// Define the shipping method for the local region (metropolitana) and for all others.
let metropolitana = 267131
let others = "22276-service"
// Function verifies if customer selected the local region (Metropolitana).
function metropolitanaIsSelected() {
return $.inArray($.trim($("#order_shipping_address_region option:selected").text()), ["Metropolitana"]) > -1;
};
// Function to hide/show the correct local method.