If stock level exceeded, nothing gets added to cart

Topic summary

Problem: Adding a quantity above available stock on the product page does nothing; the expected behavior is an error/notice prompting a lower quantity. An example product link was provided to reproduce.

Cause and fixes proposed:

  • The theme already supports an error modal for over-quantity, but a JavaScript bug prevents it from showing. In assets/shop.js, within function doAjaxAddToCart, replace e.parseJSON(n.responseText).description with $.parseJSON(n.responseText).description (use jQuery’s $ instead of e).
  • The error text is styled as white on white, making it invisible. Adjust via theme settings or add CSS such as: .ajax-error-modal .modal-inner { color: red; } in frame.scss(.liquid).

Notes:

  • This relies on the theme’s AJAX add-to-cart logic (AJAX = asynchronous request; $ refers to jQuery).
  • Code changes are central to resolving the issue.

Status: Action items identified (update JS and adjust CSS). Awaiting confirmation if the fix resolves the behavior; no final resolution reported.

Summarized with AI on January 3. AI used: gpt-5.

Your theme has this functionality.

However, there are 2 problems:

First, in your assets/shop.js find function doAjaxAddToCart and inside this function there is this code:

$(".ajax-error-message").text(e.parseJSON(n.responseText).description);

this should be

$(".ajax-error-message").text($.parseJSON(n.responseText).description);

e → $

This should bring your error message box back.

However, contents of the box are white text on white background – probably something you can change in the theme settings.
Or can add the following to the very bottom of your frame.scss(.liquid ?) asset:

.ajax-error-modal .modal-inner {
  color: red;
}
1 Like