1

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.

2
  • Have you found a solution to this issue?
    – JGeer
    Jun 30 at 13:48
  • Unfortunately no!
    – Cherry
    Jul 1 at 15:32
0

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

4
  • 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 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 at 6:26
  • Once we got the div and class then we will use javascript setTimeout function to increase its display time. May 11 at 6:28
  • Could you share some sample code on how to do that?
    – Cherry
    May 12 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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