Checking stock on basket page

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
cnoelker
Advanced
Posts: 140
Joined: 20 Feb 2016, 18:21

Checking stock on basket page

Post by cnoelker » 03 Sep 2020, 08:52

Hello,

I changed the catalog/stock/body-standard.php so that max attribute of the input field is set depending on the real stock.
This works fine. If the stock is only 3, then the HTML input field makes sure that no higher value can be entered.

Now, I noticed that the same check is not done on the basket page. So, even if the detail page limits the input to e.g. 3, then the user is able to enter a higher number on the cart page.

I checked in the CatalogController.php and think that the stockAction() is the part which initiates the inclusion of catalog/stock/body-standard.php .
The BasketController.php does not include any stockAction().
And in order to provide the necessary stockItemsByProduct, the Client/Html/Catalog/Stock/Standard.php will be needed.

What's the recommended way to handle this? Providing a custom BasketController.php which contains a stockAction()?

Claudia

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Checking stock on basket page

Post by aimeos » 04 Sep 2020, 15:50

You should implement a decorator for the basket component that fetches the stock levels of the products in the basket and add it as limit to the quantity input fields of the basket summary template:
https://aimeos.org/docs/Developers/Html ... components
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cnoelker
Advanced
Posts: 140
Joined: 20 Feb 2016, 18:21

Re: Checking stock on basket page

Post by cnoelker » 07 Sep 2020, 09:57

Thank you, I got this working.

Post Reply