Developer forum

Forum » Ecommerce - Standard features » AddToCart product limit?

AddToCart product limit?

Dmitrij Jazel
Reply

Hello DW guys,

I wanted to ask if I could make DW check how much products are beying added into the cart?

For example, if I have a product in product catalog, I can add it to the cart as many times I want it.

But what if there are 10 products in stock, and I add 75 - I wanted to know if there is a way in DW of controlling this behaviour, and not just do some workarrounds with DwTags...

 

Thanks,

Dmitrij

 


Replies

 
Dmitrij Jazel
Reply

Guys,

Anyone?

 
Marco Johannesen
Reply

Don't think there is a setting for that.

So would you want it to add the 10, or cancel the "add" ?

 
Dmitrij Jazel
Reply

What I want to do is to make it impossible to buy more than there are in stock.

Because if you have 10 products and you buy 12 - eCom will allow this, and WILL allow add more than 12 or whatever to the cart. Eventually that will push the stock to the negative. That cannot happen.

 

Any ideas?

 
Marco Johannesen
Reply
This post has been marked as an answer

Well you can hide products which arent in stock: http://developer.dynamicweb-cms.com/forum/ecommerce-standard-features/if-product-soldout-stock-is-0-or-lower--hide-from-front-end.aspx

But they can still add more than the amount which are in stock, so you need to do some custom checking for that ;-)

Votes for this answer: 1
 
Dmitrij Jazel
Reply

Hej Marco,

Thanks for response.

Well, this is surprising, why would you need to custom code this, this feature is quite popular, would be nice to have a possibility to choose allow or disallow things like that.

 

But still that does not solve the issue itself... Users still can add whatever they want to the cart.

 

Regards,

Dmitrij

 

 
Merethe Nielsen
Reply

Hi

 

It is a feature request that is already registered in our backlog (4838), but it is not prioritized to a release.

I have noted on the backlog that you also want this feature.

 

Kind regards,

Merethe

 
Dmitrij Jazel
Reply

Hej Merethe,

Yes please, It would be better than great if this could be implemented in the next release, but not sure if you will do it.

I would appreciate ALOT if you could do that :-)

 

Regards,

Dmitrij

 
Merethe Nielsen
Reply

As I wrote: It is not prioritized for a release. This means that it´s not scheduled for neither 8.2.2 or 8.3 and I don´t have the authority to add it to the plans.

 

 
Morten Bengtson
Reply

What should happen in this scenario...

Two different customers add the same products to the cart at the same time.

 

Another scenario...

A customer visits the site. There are 10 items in stock and the customer adds all 10 of them to the cart. However, he does not proceed to checkout until two days later. At that time there are only two in stock.

 

A third scenario...

If products should be "reserved" whenever someone adds products to the cart, then other customers will be prevented in ordering the same products - even though the customers who have reserved the products might not actually complete an order. When should the products be "unreserved"? When session expires? When cart expires? Never?

 
Dmitrij Jazel
Reply

Hej Morten,

Yes, I see your point, and I totally agree with those scenarios, and issues they raise on the design level of how cart works...

What I was thinking, is sticking to your first scenario, with slight adjustment.

It should be possible browse the whole shop or come back whenever... Just before final payment (just before cart-checkout step) validation error could popup. and say "you are attempting to buy more than there is in stock..."

At the same time, there could be a limit of how many products users can add to the cart. This means that if there are 10 products left, you cannot add more than 10. And it's ok as long as it does prevent adding 10 products at the time when add to cart is pressed. If there was 20 added last week, and user is back - well, than Cart - Before Checkout described earlier should prevent user from buying more than there is in stock.

I guess that could be a really handy improvement :-)

 
Nuno Aguiar
Reply

Hi Dmitrij,

 

We have developed some ajax calls to do this. We check the stock everytime a product is added to the cart, and if he tries to increase the quantity to over that limit, we correct it to the max and display an alert.

 

The final check is in the payment, of course.

 

The system should do it by default, but until then, we can share this small feature (no custom development, simple ajax calls). Interested?

 

Nuno

 
Dmitrij Jazel
Reply

Hej Nuno! :)

Oh yes, please, it would be great to look at your version of implementing this, cause I was 1 step away from coding a custom module for it - but that is something I don't really want to do. It is really nice when solution stays Clean, and no custom stuff can "harm it" if someone upgrades the version :-) who knows when...

Would appreciate that Allot! :)))

Dmitrij

 
Nuno Aguiar
Reply

Hi Dmitrij,

 

You will need to make some small adjstments:

 - Call the validateStock function whenever needed

 - The onLoadStep1 function is related to the "old" cart v1, so whenever you have a template where the user changes the quantity, load that function

 - You will also need to place some javascript in the master/page template to load the template tags correctly.

 - You need jQuery and also to correct some of our selectors.

 

I stripped down some of our code so that it's easy for you to implement it.

 

Best Regards,

 

You must be logged in to post in the forum