Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm currently in the process of building a TeaCommerce website that tracks stock for its products. I have everything setup in the backoffice but I'm struggling to find the best way to manage stock validation on the frontend.
For example when adding/updating a product to the basket, where and how should I validate the stock of that product during that workflow?
The only way I could see this working is using the OrderLineUpdating/Adding events to check the stock there and altering the user's quantity to ensure it's within the stock level. This however, doesn't seem like the best way as it's hard to inform the user of this automatic change. Alternatively, in some scenarios you might not want to alter their quantity, instead show an error message but I don't think it's possible to cancel the TC events from what I can tell?
Would be great to hear how others have managed this in the past with TC.
You are right that currently the pre-action events aren't cancelable so it's not currently possible to stop an order bring processed to do some checks. The only options I can think of are
I appreciate neither of these are ideal, but I'm just trying to outline a couple of possibilities based on the current codebase.
I hope this helps
PS For either of these approaches, there is at least an API for checking product stock levels https://docs.teacommerce.net/3.3.0/api/product/#getstock
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted