[Skip to main content](#vessel-content)

#   Qns on Product's Limit and Add to cart button

##

- **[kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")**
- [![kenneth.er's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30865-kenneth-er "View kenneth.er's Profile") Topic Author
- [ Offline](/forum/user/30865-kenneth-er)

Less More

- Posts: 22
- Thank you received: 0
-
-

12 years 5 months ago [\#155803](#155803) by [kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")  *[Qns on Product's Limit and Add to cart button](/forum/26-product-category-display/868163-qns-on-products-limit-and-add-to-cart-button#155803 "Hi,  2 questions:  &#42; I have set the purchase limit of some product to 1 per user acct. I would like to detect whether this limit has been met and remove the &quot;add to cart&quot; button accordingly.  &#42; At the moment, only the quantity field has the &quot;out of stock&quot; popup. I wonder if I can copy the same effect onto my &quot;add to cart&quot; button as well. Could you provide me with some directions? I have considered overriding the helpers/cart.php but just wondering if there's an easier way to do that.  Thank you very much!")* was created by *[kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")*

Hi,

2 questions:

1. I have set the purchase limit of some product to 1 per user acct. I would like to detect whether this limit has been met and remove the "add to cart" button accordingly.
2. At the moment, only the quantity field has the "out of stock" popup. I wonder if I can copy the same effect onto my "add to cart" button as well. Could you provide me with some directions? I have considered overriding the helpers/cart.php but just wondering if there's an easier way to do that.

Thank you very much!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NjgxNjMtcW5zLW9uLXByb2R1Y3RzLWxpbWl0LWFuZC1hZGQtdG8tY2FydC1idXR0b24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

12 years 5 months ago [\#155842](#155842) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[Qns on Product's Limit and Add to cart button](/forum/26-product-category-display/868163-qns-on-products-limit-and-add-to-cart-button#155842 "Hi,  2 questions:  &#42; I have set the purchase limit of some product to 1 per user acct. I would like to detect whether this limit has been met and remove the &quot;add to cart&quot; button accordingly.  &#42; At the moment, only the quantity field has the &quot;out of stock&quot; popup. I wonder if I can copy the same effect onto my &quot;add to cart&quot; button as well. Could you provide me with some directions? I have considered overriding the helpers/cart.php but just wondering if there's an easier way to do that.  Thank you very much!")*

Hi,
1. The only way will be to let your user add another time the product in his cart, and if he already have that product in his cart, the product won't be added to the cart with an message saying "limit exceeded". If you really want to automatically detect if your user have already a product in his cart and his the add to cart button, you'll have to use some customization code, which will require development skills.
2. Can you show me through some screenshots for example, what do you exactly mean by :

> only the quantity field has the "out of stock" popup

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NjgxNjMtcW5zLW9uLXByb2R1Y3RzLWxpbWl0LWFuZC1hZGQtdG8tY2FydC1idXR0b24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")**
- [![kenneth.er's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30865-kenneth-er "View kenneth.er's Profile") Topic Author
- [ Offline](/forum/user/30865-kenneth-er)

Less More

- Posts: 22
- Thank you received: 0
-
-

12 years 5 months ago [\#155978](#155978) by [kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")  Replied by *[kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")* on topic *[Qns on Product's Limit and Add to cart button](/forum/26-product-category-display/868163-qns-on-products-limit-and-add-to-cart-button#155978 "Hi,  2 questions:  &#42; I have set the purchase limit of some product to 1 per user acct. I would like to detect whether this limit has been met and remove the &quot;add to cart&quot; button accordingly.  &#42; At the moment, only the quantity field has the &quot;out of stock&quot; popup. I wonder if I can copy the same effect onto my &quot;add to cart&quot; button as well. Could you provide me with some directions? I have considered overriding the helpers/cart.php but just wondering if there's an easier way to do that.  Thank you very much!")*

Hi Mohamed,

Thanks for your reply.

1. At the moment, I don't even see the "limited exceeded" message. Am I to expect an alert or system message?
2. Sure. I have attached a screenshot. When I tried to increase the qty field to more than what's in my avail stock or my max limit per order, I will get this alert/popup. This is normal behaviour. However, I would like to copy this alert into the "add to cart" button. For example, I have 5 avail stock and my user clicked on the "add to cart" button 6x. I wish to have the same alert on his/her 6th button click since the stock limit has been reached. At the moment, the button simply refuse to add more to cart and does it w/o any message. This could confuse my user into thinking that the website is not working.

Thanks in advance.

- [ ![h909d48d.jpg](/forum/attachment/17261) ](/forum/attachment/17261 "h909d48d.jpg") [ ](/forum/attachment/17261?download=1 "h909d48d.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NjgxNjMtcW5zLW9uLXByb2R1Y3RzLWxpbWl0LWFuZC1hZGQtdG8tY2FydC1idXR0b24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")**
- [![kenneth.er's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30865-kenneth-er "View kenneth.er's Profile") Topic Author
- [ Offline](/forum/user/30865-kenneth-er)

Less More

- Posts: 22
- Thank you received: 0
-
-

12 years 5 months ago [\#156043](#156043) by [kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")  Replied by *[kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")* on topic *[Qns on Product's Limit and Add to cart button](/forum/26-product-category-display/868163-qns-on-products-limit-and-add-to-cart-button#156043 "Hi,  2 questions:  &#42; I have set the purchase limit of some product to 1 per user acct. I would like to detect whether this limit has been met and remove the &quot;add to cart&quot; button accordingly.  &#42; At the moment, only the quantity field has the &quot;out of stock&quot; popup. I wonder if I can copy the same effect onto my &quot;add to cart&quot; button as well. Could you provide me with some directions? I have considered overriding the helpers/cart.php but just wondering if there's an easier way to do that.  Thank you very much!")*

1. I saw the "limited exceed message". It only occurs when my user goes into the checkout page. Not sure if you could guide me on where can I find the code that does this check at the checkout page? Thanks! I will work out something from there.
2. I have solved this by modifying the update function in classes/cart.php. I added additional code to check whether the 'onAfterCartUpdate' method updates the cart. Each time there's no update, it will echo a span that contains my alert and I have jQuery to check for it to alert the user. I initially have wanted to just echo a simple js alert but it never get echo-ed out (not too sure on the reason). However, if you have a cleaner way of doing it, please enlighten me! Thanks.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NjgxNjMtcW5zLW9uLXByb2R1Y3RzLWxpbWl0LWFuZC1hZGQtdG8tY2FydC1idXR0b24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

12 years 5 months ago [\#156045](#156045) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Qns on Product's Limit and Add to cart button](/forum/26-product-category-display/868163-qns-on-products-limit-and-add-to-cart-button#156045 "Hi,  2 questions:  &#42; I have set the purchase limit of some product to 1 per user acct. I would like to detect whether this limit has been met and remove the &quot;add to cart&quot; button accordingly.  &#42; At the moment, only the quantity field has the &quot;out of stock&quot; popup. I wonder if I can copy the same effect onto my &quot;add to cart&quot; button as well. Could you provide me with some directions? I have considered overriding the helpers/cart.php but just wondering if there's an easier way to do that.  Thank you very much!")*

Hi,

1. You can potentially create a plugin based on the function "onBeforeCartUpdate()" to display a message if the product can't be added to the cart. To hide the buttons when no more quantity is available, you can edit the view "product / quantity" and get the user cart, check the quantity, and display or not the button. Using javascript could be more dynamic.

2. It can be better to do these things in a plugin based on the function "onAfterCartUpdate()". ![:)](/media/kunena/emoticons/8.png ":)")
By this way, you will not lose your changes when updating.
[ www.hikashop.com/support/support/documen...r-documentation.html](http://www.hikashop.com/support/support/documentation/62-hikashop-developer-documentation.html)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NjgxNjMtcW5zLW9uLXByb2R1Y3RzLWxpbWl0LWFuZC1hZGQtdG8tY2FydC1idXR0b24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")**
- [![kenneth.er's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30865-kenneth-er "View kenneth.er's Profile") Topic Author
- [ Offline](/forum/user/30865-kenneth-er)

Less More

- Posts: 22
- Thank you received: 0
-
-

12 years 5 months ago [\#156187](#156187) by [kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")  Replied by *[kenneth.er](/forum/user/30865-kenneth-er "View kenneth.er's Profile")* on topic *[Qns on Product's Limit and Add to cart button](/forum/26-product-category-display/868163-qns-on-products-limit-and-add-to-cart-button#156187 "Hi,  2 questions:  &#42; I have set the purchase limit of some product to 1 per user acct. I would like to detect whether this limit has been met and remove the &quot;add to cart&quot; button accordingly.  &#42; At the moment, only the quantity field has the &quot;out of stock&quot; popup. I wonder if I can copy the same effect onto my &quot;add to cart&quot; button as well. Could you provide me with some directions? I have considered overriding the helpers/cart.php but just wondering if there's an easier way to do that.  Thank you very much!")*

Hi Xavier,

1. Just to clarify, can the same idea be applied to product that has the Limit applied to them? Say in my case, I have the qty limitation on each user to 1x of certain items, and it's not the "Maximum quantity per order" limitation but the other one. So I simply wanted to know if the limit has been met, then subsequently remove the "add to cart" button.
2. Previously, I was using template overrides for the classes and helpers files, so it should still be there after each update right? Anyway, I took your advice and created a plugin instead. Thanks.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NjgxNjMtcW5zLW9uLXByb2R1Y3RzLWxpbWl0LWFuZC1hZGQtdG8tY2FydC1idXR0b24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

12 years 5 months ago [\#156719](#156719) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Qns on Product's Limit and Add to cart button](/forum/26-product-category-display/868163-qns-on-products-limit-and-add-to-cart-button#156719 "Hi,  2 questions:  &#42; I have set the purchase limit of some product to 1 per user acct. I would like to detect whether this limit has been met and remove the &quot;add to cart&quot; button accordingly.  &#42; At the moment, only the quantity field has the &quot;out of stock&quot; popup. I wonder if I can copy the same effect onto my &quot;add to cart&quot; button as well. Could you provide me with some directions? I have considered overriding the helpers/cart.php but just wondering if there's an easier way to do that.  Thank you very much!")*

Hi,

1. To know the limit on the product, it will require a request in the #__hikashop_limit table to get the informations related on the product.

2. Indeed with overrides, the files are still there after updates. But you don't have the latest core files of HikaShop and can potentially cause a conflict. Using the plugin, allow to always have the core files up to date.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NjgxNjMtcW5zLW9uLXByb2R1Y3RzLWxpbWl0LWFuZC1hZGQtdG8tY2FydC1idXR0b24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.113 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
