Skip to content

Instantly share code, notes, and snippets.

@guilhermemarconi
Last active October 30, 2015 14:27
Show Gist options
  • Save guilhermemarconi/827b830f463be1e44fde to your computer and use it in GitHub Desktop.
Save guilhermemarconi/827b830f463be1e44fde to your computer and use it in GitHub Desktop.
body.on('click', '.js-add-to-cart', function(event) {
var sizeSelected = $('.size-selected').find(':selected'),
skuId = parseInt($('.size-selection').val()),
skuQty = parseInt($('.qty-selection').val()),
skuName = sizeSelected.text(),
skuPrice = sizeSelected.data('sku-price'),
skuCache = $('.size-selection').data('cache-version'),
requestUrl = '/checkout/cart/add?sku=' + skuId + '&qty=' + skuQty + '&price=' + skuPrice + '&seller=1&cv=' + skuCache + '&sc=1';
event.preventDefault();
swal({
title: "Escolheu o tamanho certo?",
text: "A maior parte das trocas ocorre por equívoco de tamanho. Confira o <a href='#' class='js-open-size-guide'>guia de medidas</a> caso tenha dúvidas.",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#00c6ab",
confirmButtonText: "Adicionar ao Carrinho",
cancelButtonText: "Conferir",
closeOnConfirm: true,
closeOnCancel: true,
html: true
}, function(isConfirm) {
if (isConfirm) {
$.get(requestUrl).complete(function() {
vtexjs.checkout.getOrderForm().done(function(orderForm) {
updateCartQuantity(orderForm);
mountCart(orderForm);
$('.js-open-minicart').trigger('click');
});
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment