Developer forum

Forum » Templates » Products added to cart

Products added to cart

Mikkel Ulstrup
Reply

Hi,

How can see what products have been added to the cart when posting with the "CartCmd:add" and "CartCmd:addmulti"?

All I can find is some "LastAddedProduct"-tags, but those exists even if the product is not added to the cart (if not enough in stock), and it is useless for "addmulti".

 

Kind regards

Mikke Ulstrup


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Mikkel

I think that is what is available. EcomLastAddedProduct contains only the last added product - so if you use add multi, they all get added but only the last one as last added product.

In our own more recent implementations we add to cart with ajax and can respond to that in the UI since it all happens without reloading - in your ajax return of the cart, you can see what is in the cart so if products are out of stock, and you still show an add to cart button, you can verify the check when they get back. But if you have configured your solution to not support adding products out of stock to the cart, you should also remove the buy option.

An alternative to this, is to add your own server side logic using notification subscribers.

BR Nicolai

Votes for this answer: 1
 
Mikkel Ulstrup
Reply

Hi Nicolai,

 

Thanks for answering! That sugested solution is close to the solution we use most of the time.

 

But if you have configured your solution to not support adding products out of stock to the cart, you should also remove the buy option

This does not work if there are 10 in stock, but you try to add 20 to the cart. The time between the pageload and the "add-to-cart click" also opens up for the risk of other customers buying the last stock. The last could very well be the case when adding discounts/campaigns to products you intend to sell out.

 

I will make a feature request. :)

 

Kind regards

Mikkel Ulstrup

 

You must be logged in to post in the forum