1. Home
  2. Docs
  3. Product Stock Notificatio...
  4. Installation
  5. Enable Stock Alert Popup on Category Pages and Product Grids

Enable Stock Alert Popup on Category Pages and Product Grids

By default, when a customer clicks the button from a category page, product grid, module, or other listing section, the flow may redirect the customer to the product page.

If you want the stock alert popup to open directly from category pages, product listings, or product grids, an additional JavaScript update is required in your theme files.

Why this manual change is needed

This part cannot be applied through OCMOD because OCMOD does not modify JavaScript files directly in this case. The required code must be added manually to the relevant JavaScript file used by your active theme.

For the default OpenCart theme, the file is usually:

catalog/view/javascript/common.js

Some custom themes may use a different JavaScript file for cart actions. If you are using a third-party theme, the correct file path may vary.

If you are unsure which file to edit, you can contact support for assistance. Without this customization, the button will normally direct the customer to the product page instead of opening the stock alert popup directly in the listing.

What you need to look for

Find the JavaScript function that is triggered by the Add to Cart button.

For the default OpenCart theme, this is usually:

cart.add

Search for:

var cart = {
and then locate the:

add: function(...)

Inside that function, find the AJAX success block. Just above this condition:

if (json['success']) {

add the following code:

if (json['hberror']){
    if (json['hberror']['oosn']) {
        notifypop(json['hberror']['oosn']);
        return false;
    }
}

Result after adding this code

Once this code is added correctly, clicking the stock alert button from category pages, product grids, modules, or similar listing sections will open the notification popup directly instead of redirecting the customer to the product page.

This provides a faster and smoother user experience and can improve subscription rates for out-of-stock products.

Important note

If your theme overrides the default cart JavaScript behavior, the same logic must be added to the corresponding custom function used by that theme.

If needed, support can help identify the correct JavaScript file and implement this change for your OpenCart store.