Prepopulate the cart with items
Is there any way to setup ecart that there is an item always in the shopping cart. I want to add an item. Without the user having to add it themselves, one item that is there always.
Is there any way to setup ecart that there is an item always in the shopping cart. I want to add an item. Without the user having to add it themselves, one item that is there always.
One way you could do this would be to put an add to cart server behavior on a page that you know the user will go to regardless, like the product listing page or the cart.
The idea is that you have this add to cart server behavior on the page and the trigger is based on a session variable being set. Since this session variable will not be set by default the add to cart will run and add the item. You then edit this server behavior on the page to add in the code to set the session variable. This way after the code has run the item will be added but not again.
There are other ways you can do this also, you can give the item a unique id, then have an add to cart server behavior that is triggered on this item not being in the cart and just have it added. Please post back with any questions you have about any part of this.
Yes thanks for the answer. Is it possible you could give in point form the steps to follow need just a bit more help with the second solution (seems like the easier one).
Give the item an unique id? With a add to cart server behaviour?
Can you break down in a few steps.....
Thanks
Sorry for that last part being so short. For the unique id I'm just referring to the item id that you assign in the add to cart server behavior. The item's id will need to be unique to that item only. Each item that you have an add to cart for should have a unique id so this is no different than the other items.
Once you have the add to cart on the page you can update the trigger for the add to cart, it might look like this by default:
// WA eCart AddToCart
if (isset($_POST["WA_Store_Cart_1_ATC"]) || isset($_POST["WA_Store_Cart_1_ATC_x"])) {
You will need to update it with the eCart code that will check for the specific item in the cart, this check is based on the item id. In this example the item has an id of 5.
// WA eCart AddToCart
if ($WA_Store_Cart->InCart("5") != true) {
This code is saying 'if item 5 is not in the cart then proceed'. The rest of the code is just the regular add to cart code so it will just add this item to the cart. In this code it works like this:
this part represents the name of your cart
$WA_Store_Cart
This part is checking for the item
->InCart("5")
This final part just says 'if not true' meaning the item is not in the cart
!= true
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.