minicart
minicart copied to clipboard
cart.on 'checkout' event order problem
I have a simple site that has 2 products. These products are sometimes sold by deal sites and redeemed through our site using a discount code.
I have created a process to check for these "free" items, amount = 15.99 and discount_amount = 15.99 and if subtracting those <= 0.00 it processes those free items and removes from cart on checkout.
Problem is that often the cart will still try to push all of those products to paypal and it appears that in those instances, the cart.on checkout is never fired.
Here is my code:
paypal.minicart.cart.on('checkout', function(evt) {
$('.minicart-submit').hide();
$('<span id="pleasewaitcart">Please Wait...</span>').insertBefore('.minicart-submit');
var products = paypal.minicart.cart.items();
var freeProducts = new Array();
for (var i = 0; i < products.length; i++) {
if (parseFloat(products[i]._data.amount) == parseFloat(products[i]._data.discount_amount)) {
alert('Adding free product: '+products[i]._data.item_number);
freeProducts.push(products[i]);
paypal.minicart.cart.remove(i);
}
}
alert('sending '+freeProducts.count+' for processing');
processCart(freeProducts);
evt.preventDefault();
return false;
});
We are launching a Living Social deal in about 5 days and I have spent hours trying to figure this out. please help! :)
Thanks in advance, Jason
Check out my comment on the issue: https://github.com/jeffharrell/minicart/issues/239
Thanks to the PR from @jakeday this should be fixed as part of 3.0.6.