Hi
When I use JQuery to auto-add items to the cart, I usually call the AddToCart.aspx page using a JQuery Ajax call.
I find this makes life a lot simpler because you can ignore/remove all the existing addtocart Javascript (and even the AddToCart function in the XmlPackages) and replace it with something like this:
Code:
var $url = "addtocart.aspx?Quantity="+$qty+"&ProductID="+$productid+"&VariantID="+$variantid+"&returnurl=/shoppingcart.aspx";
$.ajax({
url: $url,
success: function(data) {
// Do something here to show the user what's happened. e.g. minicart, alert etc.
}
});
This is a simple example without color/size but you can add these also if you like. Obviously, you need to create the $qty, $productid, $variantid variables as required.
You get complete control over what's going on, you can put this on any page and because you've probably removed all the existing Javascript, it also makes the page source much tidier and arguably more search engine friendly.
Adam
Webopius.com