Skip to content

Instantly share code, notes, and snippets.

@marioloncarek
Created October 9, 2018 09:18
Show Gist options
  • Save marioloncarek/12b3a3cbff0c70b6db38c4762324c842 to your computer and use it in GitHub Desktop.
Save marioloncarek/12b3a3cbff0c70b6db38c4762324c842 to your computer and use it in GitHub Desktop.
addBundleToCart.addEventListener('click', (event) => {
event.preventDefault();
const productId = document.querySelectorAll('.js-ajax-bundle-form');
const concatedProductIds = [];
let concatedProductIdsString = '';
for (let i = 0; i < productId.length; i++) {
console.log(productId[i].getAttribute('data-product-id'));
if (i !== (productId.length - 1)) {
concatedProductIdsString += `${productId[i].getAttribute('data-product-id')}, `;
} else {
concatedProductIdsString += `${productId[i].getAttribute('data-product-id')}`;
}
}
concatedProductIds.push(concatedProductIdsString);
console.log(concatedProductIds);
addAllItems(concatedProductIds);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment