Contributions
Automatically add multiple products with attribute to cart from external source
This file will allow you to create a URL string that will automatically add multiple products and attributes to the cart and display the cart. All you need to do is put this file in the root of your store and then create the URL.
eg of URL:
http://www.yourdomain.com/catalog/addproducts.php?product_id=40{1}2,40{1}5,43{3}4
| 24 May 2011 |
UPDATE BY: Richard Woolf / rfwoolf
This new version has 1 MAIN IMPROVEMENT and 1 WARNING:
IMPROVEMENT:
Up until now, you could add several products with 1 attribute.
But what if you have several attributes, like this:
..addproducts.php?product_id=28{8}17{7}15{9}19[1]
In the above URL, there are 3 attributes being set.
You can now have as many or as little attributes as you want.
Also, it is less sensitive, so if you leave off a bracket or something, it's okay - it will just ignore that attribute or quantity.
WARNING:
I have made it so that it specifically *adds* to your shopping cart (for some reason with me, if I had 1 in my cart and I add another 1, it was still 1).
To change this back, edit the file and change the SECOND parameter of add_cart:
CHANGE ALL OF THESE:
//(makes the cart quantity what it was PLUS your new quantity)
$cart->add_cart($productID, ($cart->get_quantity(tep_get_uprid($productID, $attributes))+$productQuantity), $attributes);
TO THIS:
//(makes the cart quantity your new quantity):
$cart->add_cart($productID, $productQuantity, $attributes);
CHANGE ALL OF THESE:
//(makes the cart quantity what it was PLUS 1)
TO THIS:
$cart->add_cart($productID, 1);
| 8 Apr 2011 |
Note: Contributions are used at own risk.
