How do I prevent "The requested qty is not available" message from autohiding in product page while adding products to cart. I want to let user close the message instead of auto hide? I was able to fix the similar issue in checkout page by updating messages.js file.

But unable to locate the code from where to fix this.

  • Have you found a solution to this issue?
    – JGeer
    Jun 30, 2021 at 13:48
  • Unfortunately no!
    – Cherry
    Jul 1, 2021 at 15:32
  • Which version of Magento are you using? I have the same issue on a M2.4.3-p2 instance.
    – Akif
    May 4, 2022 at 12:54

1 Answer 1


Next time whenever the message come "The requested qty is not available" then right click on that and open inspect element, then using some local jquery code we will remove its css class, so that it should not disappear.
This is a model file I found may be useful - /var/www/html/development_m241/m241/vendor/magento/module-quote/Model/Cart/AddProductsToCart.php

  • The message is on screen just for fraction of seconds, hardly user can read it. And I cannot locate mention file in Model folder. I am using Magento 2.4.
    – Cherry
    May 11, 2021 at 5:20
  • This file may be important - /var/www/html/development_m241/m241/vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml from your root follow this path - vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml , you may need to override this file because direct changes are not recommended. May 11, 2021 at 6:26
  • Once we got the div and class then we will use javascript setTimeout function to increase its display time. May 11, 2021 at 6:28
  • Could you share some sample code on how to do that?
    – Cherry
    May 12, 2021 at 15:11
  • -1 for fast and bad response May 17, 2022 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.