Stock Indicator
(BU)Stock Indicator displays a progress bar for a WooCommerce product with quantity tracking. The filled portion shows the share sold relative to units sold plus stock on hand. Use the bar near a product's purchase controls or in a custom product card, with a text label if you want to show the exact quantities.
Enable and Place the Element
- Make sure WooCommerce inventory management is enabled under WooCommerce → Settings → Products → Inventory.
- For a simple product, enable stock quantity tracking and enter the stock quantity in its Inventory settings. For a variable product, configure quantities on the individual variations you want to track. Merely setting a product to In stock does not give the indicator a stock count.
- In Bricks → BricksUltimate → Woo Elements, enable Stock Indicator and save. Reopen the Bricks editor and search for (BU)Stock Indicator.
- On a single-product template, place it near the price or Add to Cart controls. In a product grid, put it inside the repeated card so it reads the current loop item. There is no Product ID override. For template previews, select a stock-managed product under Populate Content.
- Set the bar styles and test on the storefront. The bar shown in the Bricks editor is a 45% styling example, not the live result.
Understand the Progress Bar
The percentage is calculated as units sold / (units sold + current stock) × 100, rounded to a whole number. For example, 30 sold and 70 in stock fills 30% of the bar. No recorded sales means no fill. A product with recorded sales and zero stock can show a full bar.
The bar is not the percentage of stock remaining or the progress of a specific shipment. It uses WooCommerce's recorded sales count and current stock, so replenishing inventory can reduce the filled portion. It does not change stock, manage backorders, or prevent checkout.
For a variable parent, the initial bar uses the parent's sales count and the sum of stock quantities across visible variations. At least one visible variation must report managed stock. Because the parent calculation adds variation quantities, validate it before displaying a combined figure for products that share one stock pool.
Show Stock and Sales as Text
The indicator itself only renders the bar. Add a Bricks Basic Text element beside it and use dynamic tags in the same product context:
{product_total_sales}: The product's recorded sales count. Example:Sold: {product_total_sales}.{bu_product_available_stock_quantity}: The current stock quantity used for the indicator's initial product-level display. For a variable parent, it sums the quantities of visible variations. Example:Available: {bu_product_available_stock_quantity}.{bu_product_stock_quantity}: The current product object's own stock value. It does not aggregate visible variations or supply the markup needed for the indicator's live variation text.
Use the first two tags for text that should update with the selected variation. Keep labels clear, and only expose stock counts if your store wants shoppers to see them.
Update the Bar When a Variation Is Selected
- Use a Bricks single-product template for a variable product and keep a working WooCommerce variation form on the page. (BU)Add To Cart loads BricksUltimate's variation-handling script.
- Add a Block around the indicator and any stock text. Give it a unique CSS class, such as
product-stock-summary. Keep the purchase form outside this wrapper, because the wrapper can hide when a variation has no stock indicator data. - In the Stock Indicator, set Context selector to
.product-stock-summary. Include the dot for a class selector. If you use an ID, include the leading#instead. - Inside that wrapper, add the optional
{product_total_sales}and{bu_product_available_stock_quantity}text. The variation script updates those values together with the bar. - On the storefront, select all required attributes for two variations with different tracked quantities. Clear the selection and check that the original product-level display returns. A selected variation without an indicator can hide the stock wrapper.
The live variation switch is for single-product layouts outside query loops. A grid shows a product-level bar per card, or a bar for a specific variation when that variation is itself the loop item. Do not expect loop swatches to update the indicator. Variation sales may use a legacy order-item count when no positive sales total is recorded, so do not treat the variation figure as a precise units-sold report, particularly on stores using WooCommerce High-Performance Order Storage (HPOS).
Style the Indicator
- Height: Set the thickness of the track. The default stylesheet uses a 7px track.
- Default color: Sets the background of the track.
- Active color: Sets the color of the filled portion. Choose enough contrast against the track.
- Bar border: Styles the track border. Use the surrounding Block to set the overall width, spacing, and placement.
- Disable if low stock: Intended to hide the indicator at the product's configured low-stock amount. The current renderer checks the switch before reading the element settings, so it does not reliably hide the bar. Do not rely on it for conditional visibility.
Troubleshooting
- The element is missing: Enable Stock Indicator under Woo Elements and reopen Bricks. On the storefront, verify that the template or loop is rendering a WooCommerce product with managed stock.
- The track does not fill: Check that WooCommerce has recorded sales for that product. Having stock by itself does not fill the bar.
- The bar or counts do not change with the variation: Use a single-product layout, check that the selector matches one wrapper, and test a fully selected variation with tracked stock. Use the exact dynamic tags above for text updates.
- The amount differs from the admin inventory or sales report: Check whether the bar is using the parent or a variation, whether stock is shared, and whether the page was cached before the latest order or restock. Use WooCommerce inventory and reports for operational figures.
- You only need availability or restock alerts: Use the Sold Out Badge for an out-of-stock label or Back In Stock for a notification signup form.