![]() |
adding free items to cart
Hello,
I am offering free items in my store and I'd like these free items to be AUTOMATICALLY added to a customers shopping cart when they add ANY item to their shopping cart. i.e if a customer wants to buy a xbox game, i'd like the free xbox game that i'm offering to be added automatically to his/her shopping cart. Does anyone has a code to help me do this? I'd appreciate your help on this matter. Thanks |
exact code
I don't know the exact code to do it, but I would assume that on the detail page of the product, you could put some other hidden inputs so that you were adding the other product to the cart at the same time in the background.
That make sense? Poke around a bit on the detail product tpl - skin1/customer/main/product.tpl - and see if you can get some hidden inputs going in there. Hope that helps! |
Here is a nice mod that I used to solve this problem. Doesn't automatically add the item to the cart, but it still works well:
http://forum.x-cart.com/viewtopic.php?t=18380 |
Automatically adding free items
I had the same situation you had. I wanted to automatically add free items to each user's shopping cart. I am running version 4.0.12. Here is the reply I got from tech support. Hope it helps.
Please perform following steps : 1. Open '<xcart_root_dir>/cart.php' file. 2. Replace : Code:
--- Code:
--- For example : -- if ($productid<>16126) func_header_location($xcart_catalogs['customer']."/cart.php?mode=add&productid= 16126&amount=1"); -- -- |
Thanx for sharing.
|
Re: Automatically adding free items
Quote:
Im trying to get this working on 4.0.14 and its not adding the item to the cart and causing the cart to freeze at points, does anyone know what the updated code would be for my version, thanks in advance. |
Re: adding free items to cart
Really appreciate some help on this one as well
Anyone! |
Re: adding free items to cart
The above code will add the free product to every order. If you just want free products with other specific products use this:
PHP Code:
For example: If someone purchases productid 5 (and X-Box), it will automatically add productid=20 (a free game). The bad thing about this code is that you will have to add these lines for every product that you want to have a freebee with. A better way would be to add a field to the database called free_products and then check for every added product is there is a freebee. But this way will work. |
Re: Automatically adding free items
Quote:
You need to remove the space before the product number. |
Re: Automatically adding free items
Quote:
Quote:
Bill - I cannot thank you enough for solving that one for us! Just 2 questions:- The most important one is how can you limit the free product qty to 1 item only regardless of how many products are put in the cart (the code above adds a free item every time a product is added but our store is giving a free gift per order made not per product. Is there code that could be added that checks that the cart has a product in it (other then the free one). At the moment if someone puts a product in the cart the code above adds the free item (or whatever item specified) to the cart, but if the original item is then deleted from the cart , this free item remains there. Is there a bit of code that can check for this? As it is the item I am specifing is a free item and the cart will not allow a checkout with a subtotal of $0.00 but if this code was straight forward it would be nice. Many thanks Simon |
Re: Automatically adding free items
Quote:
Sorry, I don't have an easy solution for you on these. You will either have to dig into the cart functions, or have a custom mod that limits the quantity based on price, and delete all products when the cart has items but the total is 0. |
All times are GMT -8. The time now is 11:37 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.