This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function() { | |
var productIds; | |
function productsCSV(){ | |
$.ajax({ | |
method: 'GET', | |
url:'/api/checkout/pub/orders/order-group/'+{{ORDER ID}}, | |
async: false | |
}).then(function(resp){ | |
productIds = resp[0].items.map(function(product){ return product.refId }).join(','); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//function that returns a string of productIds separated by commas | |
for (var idx in dataLayer) { | |
if (dataLayer[idx].hasOwnProperty('ecommerce')){ | |
return dataLayer[idx].ecommerce.purchase.products.map(function(product){ return product.id }).join(',')); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var currentPostalCode = ""; | |
$(window).on('orderFormUpdated.vtex', function(ev, orderForm) { | |
if(orderForm && orderForm.shippingData && orderForm.shippingData.address && currentPostalCode != orderForm.shippingData.address.postalCode){ | |
currentPostalCode = orderForm.shippingData.address.postalCode; | |
var params = ({'postalCode':{'value':currentPostalCode}}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Depends on JQUERY | |
//Depends on CL Entity's rclastcart field to be public to read | |
(function(accountName,identityExpiration) { | |
function setOrRenewUserEmailToSession(email) { | |
if(email && email != "") { | |
if(localStorage) { localStorage.setItem("vtex-user-email", email) }; | |
if(vtex && vtex.NavigationCapture) { | |
//Saves user cart, for abbandoned cart. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
//AVOIDS AN INFINITE LOOP | |
var tries=0; | |
var maxTries=5; | |
var callFunctionOrSetTimeout = function(){ | |
tries++; | |
if(window.vtexjs&&window.vtexjs.checkout&&window.vtexjs.checkout.orderForm){ | |
console.log('Data available'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example input | |
var item = { id: 35, quantity: 3, seller: 1 } | |
var attachments = [ | |
{ | |
name: "Ingredientes Hamburguesa con Queso", | |
values: [ | |
{ | |
"Sin Carne 50gr": "true", | |
"Sin Cebolla": "false", | |
"Sin Mostaza": "false", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//dependencies jquery e jquery cookie | |
//https://plugins.jquery.com/cookie/ | |
function logout(){ | |
$.removeCookie('VTEXSC', {domain:'.'+window.document.domain}); | |
$.removeCookie('checkout.vtex.com', {domain:'.'+window.document.domain}); | |
$.get(vtexjs.checkout.getLogoutURL()); | |
$.get('/no-cache/user/logout'); | |
setTimeout(function(){window.location = "",500); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var categories = []; | |
var brands = []; | |
function slugify(text) | |
{ | |
return text.toString().toLowerCase() | |
.replace(/\s+/g, '-') // Replace spaces with - | |
.replace(/[^\w\s-]/g, '-') // remove non-word [a-z0-9_], non-whitespace, non-hyphen characters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
//Carriers that accepts Cash on Delivery | |
var carriesCashOnDelivery = [ | |
'Delivery' //Carrier name | |
]; | |
var paymentGroupCashOnDelivery = '#payment-group-custom201PaymentGroupPaymentGroup'; //Cash On Delivery Payment Group | |
var defaultPaymentGroup = '#payment-group-creditCardPaymentGroup'; //Default Payment Group | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
$('#shipping-data').on('enable.vtex', function(){ | |
console.log('Shipping Data just opened.'); | |
}); | |
$(window).on('orderFormUpdated.vtex', function(ev, orderForm) { | |
console.log('Order Form updated.'); | |
}); | |
NewerOlder