Live Stock Refresh
An opt-in feature that keeps stock state and Add-to-Cart buttons live on fully-cached pages — the same idea as AJAX pricing, applied to stock.
Table of Contents
The problem it solves
If you full-page-cache your shop and product pages, the cached HTML freezes whatever stock state was current when the page was cached. A product that sells out can keep showing “In stock” (and a working Add to Cart button) to every visitor until the cache is purged. Excluding those pages from the cache fixes the accuracy but throws away the performance.
Live Stock Refresh lets you keep the pages cached and still show correct, current stock: in the same batched AJAX request that fetches prices, the plugin also fetches fresh stock text and Add-to-Cart markup for each product and swaps them in.
What gets refreshed
When enabled, for every product on the page the plugin refreshes:
- Stock availability text — e.g. “5 in stock”, “Out of stock”, or nothing, exactly as WooCommerce would render it now.
- The loop Add to Cart button — including the case where a now-out-of-stock product should show “Read more” instead of “Add to cart”.
There is no extra round-trip — stock rides along in the same get_wc_prices request as prices.
How to enable
- Go to Super Speedy → AJAX Prices.
- Tick Refresh stock via AJAX.
- Save.
Exclusions
Stock refresh follows the same rules as prices:
- It only applies to published products.
- It’s skipped for logged-in users if you’ve enabled Disable for logged-in users.
- It’s skipped when the cart has items if you’ve enabled Disable when cart has items.
This keeps the price and stock halves of every response consistent — you never get refreshed prices with stale stock or vice-versa.
How to verify it’s working
- Enable the setting.
- Load a cached category page. In the page source you’ll see stock elements tagged with
class="… ajax-stock"and loop Add-to-Cart links tagged withssap-add-to-cart. - In DevTools Network, the
get_wc_pricesresponse now contains astockobject alongsideprices. - To prove it’s live: change a product’s stock in the admin (or let one sell out), then reload the cached page. The stock text and button update to the new state even though the HTML came from cache. After the swap the elements carry the
ajax-stock-loadedclass.
Notes & limitations
- Stock refresh adds a little server work per request (it renders each product’s stock and Add-to-Cart markup), which is why it’s off by default. On normal-sized grids this is negligible; the per-request product cap still applies (see Developer Reference →
ssap_max_products_per_request). - The refreshed markup is WooCommerce’s own server-rendered HTML, so it matches your theme’s styling.
- For Product Bundles and Composite Products, the response also carries richer per-child/per-component stock data — see Compatibility & Integrations. Developers can add their own per-product fields via the
ssap_stock_data_for_productfilter (Developer Reference). - The
wc_ajax_inventory_updatedJavaScript event fires after stock is swapped in, so custom scripts can react to live stock data (Developer Reference).