<script type="text/javascript">
function processNext(urls, i) {
var next = i + 1;
$('processing-text').update('Processing item ' + next);
if (next < urls.size()) {
new Ajax.Request(urls[i], {
method: 'get',
onComplete: function(transport) {
processNext(urls, next);
}
});
} else {
new Ajax.Request(urls[i], {
method: 'get',
onComplete: function(transport) {
window.location.reload();
}
});
}
}
function addItemsToCart() {
$('add-items-to-cart').hide();
$('waiting').show();
var addToCartUrls = [];
$$('input.add').each(function(e){
if(e.checked == true) {
var id = e.readAttribute('id').split('_')[1];
var qty = Number($('qty_' + id).value);
if (qty < 1) qty = 1;
addToCartUrls.push($('url_' + id).value + 'qty/' + qty);
}
});
if (addToCartUrls.size() > 0) {
processNext(addToCartUrls, 0);
} else {
$('add-items-to-cart').show();
$('waiting').hide();
alert('Please check off the items you want to add.');
}
}
</script>Referred from:
Linden LAN » Blog Archive » How To Simultaneously Add Multiple Products To A Magento Shopping Cart
No comments:
Post a Comment