0
Below is what I managed to do:
When I click on a button with the class .btn-comprar-na-pagina
, it fires function below.
$(function () {
var itens = [];
$(document).on("click", ".btn-comprar-na-pagina", function (e) {
e.preventDefault();
var hrefSelf = $(this).parent().parent().find('.buy-in-page-button').attr('href');
var sku = txt[0].replace("sku=", "");
var qtd = $(this).parents('.box_produtos').find("input.qtd.pull-left, .input-number").val();
//remove sku se existir em itens
itens.forEach((item, index) => {
if (sku.indexOf(item.id) > -1)
itens.splice(index, 1)
});
var item = {
id: sku,
quantity: qtd,
seller: '1'
};
itens.push(item);
});
});
Using the array in another capacity:
$(function(){
$(document).on("click", ".btn-2", function (e) {
e.preventDefault();
checkout.insertToCart(items, null)
.done(function (order) {
alert('Kit adicionado ao carrinho');
});
});
if this list is a global variable you can access it from any method
– Sérgio S. Filho
Your question is unclear... you can add more code?
– Sergio
and simpels to do, problem and how this your code, like, and complicated guess what will work for Voce
– Neuber Oliveira
I edited the question....
– wbp
@wbp, if the answer to below solves your problem, mark it as solved; otherwise post your solution.
– Valdeir Psr