What is Product Badge Rules?
Product Badge Rules (by Storzen) adds automatic product badges and labels to your WooCommerce store. Instead of editing every product by hand, you create a badge once, pick a rule, and the plugin shows it on every product that matches — and stops showing it the moment the product no longer matches.
Badges are plain HTML and CSS rendered on your server. There is no front-end JavaScript, one stylesheet loads only on WooCommerce pages that actually show a badge, and all active badges are fetched in a single cached query.
System Requirements
WooCommerce is a hard dependency. The plugin declares it in its header (Requires Plugins: woocommerce) and shows an admin notice if WooCommerce is missing. No external services or libraries are needed.
| Component | Minimum | Notes |
|---|---|---|
| WordPress | 6.3 | Tested up to 7.1 |
| PHP | 8.0 | Typed code, namespaced classes |
| WooCommerce | 8.0 | Required. Tested up to 11.2 |
| Database | MySQL / MariaDB | One custom table, {prefix}badgify_badges, created on activation |
Installation
From WordPress.org (Recommended)
Search in Plugins
In your WordPress admin go to Plugins → Add New and search for “Storzen Product Badge Rules”.
Install & Activate
Click Install Now, then Activate. The plugin creates its database table and adds three starter badges (Sale, New, Hot) on first activation.
Open the menu
Click Product Badge Rules in the admin sidebar and open All Badges.
Manual Upload
Download the ZIP
Download storzen-product-badge-rules-for-woocommerce.zip.
Upload via Admin
Go to Plugins → Add New → Upload Plugin, choose the ZIP and click Install Now.
Activate
Click Activate Plugin. Make sure WooCommerce is installed and active first.
The three starter badges are live as soon as you activate: a red Sale badge, a green New badge (products from the last 30 days) and an orange Hot badge (50+ sales). Edit or delete them any time.
Quick Start
Create your first badge in about a minute. This example adds a “Save 30%” style badge to every product on sale.
Add a badge
Go to Product Badge Rules → All Badges and click Add New Badge.
Name it and choose a rule
Enter an internal Badge Name (customers never see it) and choose On Sale as the Trigger Rule.
Write the label
Set Label Text to Save {pct}. The {pct} token is replaced with the real discount, so a product at 30% off shows “Save 30%”.
Style it
Pick background and text colours, a shape and a position. The live preview updates as you type.
Save
Click Save Badge. Open your shop page — the badge is already live.
With Display → Replace WooCommerce Sale Flash on (the default), WooCommerce’s own bubble is hidden on every product that shows one of your badges, so products never carry two sale badges.
How a Badge Is Chosen
For each product the plugin walks through your active badges in priority order and shows the first one that matches. The free version shows one badge per product.
Per-product override
If the product is set to Hide badge, nothing is shown and no rules are evaluated.
Active & scheduled
Only badges with Status on and inside their optional Active From / Until window are considered.
Rule + category match
Badges are checked in Priority order (lowest number first). A badge matches when its rule matches and the product is in one of the badge’s target categories (or no categories are set).
Custom text (optional)
If the product is set to Custom text, your text replaces the label of the matched badge — or, when no rule matches, a neutral dark badge is shown.
Give the most important badge the lowest priority number. For example Sold Out at 5, Low Stock at 8, Sale at 10 — a sold-out product on sale then shows “Sold Out”, not “Sale”.
The 9 Badge Rules
The Trigger Rule decides which products get a badge. Rules read live WooCommerce data, so badges appear and disappear on their own.
| Rule | Matches when… | Rule value |
|---|---|---|
| On Sale | WooCommerce reports the product as on sale (is_on_sale()) | none |
| New Arrival | The product was published within the last N days | days (empty = global setting, 30) |
| Featured | The product is marked Featured in WooCommerce | none |
| Low Stock | Stock is managed, the product is in stock and quantity is between 1 and the threshold | threshold (empty = global setting, 5) |
| Out of Stock | The product is not in stock | none |
| Hot Seller | Total sales reach the minimum | min sales (empty = global setting, 50) |
| On Backorder | Stock status is “On backorder” | none |
| Price Range | The current price is inside a min–max range | min and/or max price |
| Product Tag | The product has at least one of the selected product tags | one or more tags |
On Sale
saleUse {pct} in the label to show the discount, for example Save {pct} → “Save 30%”. For variable products the percentage compares the highest regular price with the lowest sale price.
New Arrival
newBased on the product’s published date. Leave the rule value empty to use the global Rule → New Arrival — Days setting.
Low Stock
low_stockNeeds Manage stock enabled on the product. Use {qty} in the label: Only {qty} left! → “Only 3 left!”. Out-of-stock products are not “low stock” — use the Out of Stock rule for those.
On Backorder
backorderFor “Pre-order” or “Ships in 2 weeks” labels. A product set to On backorder is still purchasable, so it does not match the Out of Stock rule.
Price Range
price_rangeEnter a Min, a Max, or both. Leave Max empty for “and above” (a Premium badge from 100), or Min empty for “up to” (an Under $20 badge with Max 20).
The current price is used, so a product on sale is judged by its sale price. Variable products use their lowest variation price. Products without a price never match.
Product Tag
product_tagTick one or more tags — for example Eco-friendly or Gift idea. The picker lists your 200 most-used tags plus any tag already selected on the badge.
Saving a Price Range badge with no min/max, a range whose maximum is below its minimum, or a Product Tag badge with no tag is rejected with a clear message so you never end up with a badge that can never match.
Label Tokens
Tokens are placeholders in the Label Text that the plugin replaces with real values for each product.
| Token | Works with | Result |
|---|---|---|
| {pct} | On Sale rule | Discount percentage, rounded — Save {pct} → “Save 30%” |
| {qty} | Low Stock rule | Units left — Only {qty} left! → “Only 3 left!” |
Tokens only work with the rule listed. Used with any other rule they are left in the text as typed.
Badge Designer
Every badge has its own colours, shape and position, with a live preview in the editor.
Colours
Choose a Background and Text Color with the WordPress colour picker.
Shapes
Positions
Eight positions on the product image — the four corners and the four edge midpoints. The centre is intentionally left free.
Slugs used in the database and CSS:
top-left top-center top-right middle-left middle-right bottom-left bottom-center bottom-right
Raise Display → Badge Z-Index (default 99). Values like 999 fix most theme overlays.
Scheduling & Priority
Scheduling
Set Active From and/or Active Until to run a badge for a limited time — Black Friday, a launch week, a holiday sale. Outside the window the badge is hidden automatically. Leave both empty to always show it.
Priority
When more than one badge matches a product, the one with the lowest priority number wins. The starter badges use 10 (Sale), 20 (New) and 30 (Hot).
Status
Switch a badge on or off with the Status toggle — in the editor or straight from the badge list — without deleting it.
Category Targeting
In the badge editor, the Category Targeting section lists your product categories. Tick one or more and the badge only appears on products assigned to those categories. Leave all unticked to show the badge on every product.
Targeting matches the categories a product is directly assigned to. Ticking a parent category does not automatically include products that sit only in its sub-categories — tick the sub-categories as well.
Category targeting combines with the rule: a Summer Sale badge using the On Sale rule and the “Summer” category shows only on sale products in Summer. A sale product in another category falls through to your next matching badge, such as a general Sale badge.
Per-Product Override
Sometimes one product needs its own treatment. Every product has a Product Badge box on its edit screen, and the same options appear in the product list Quick Edit panel.
- Auto
- The badge rules decide. This is the default and stores nothing.
- Hide badge
- No badge on this product, whichever rules match. With Replace WooCommerce Sale Flash on, WooCommerce’s own “Sale!” bubble is hidden too, so the product shows no badge at all.
- Custom text
- Your own label, up to 30 characters.
How custom text looks
- If a badge rule matches the product, your text replaces that badge’s label and keeps its colours, shape and position.
- If no rule matches, a neutral dark badge (dark grey, white text, rounded, top-left) is shown. Developers can change this with the
badgify_custom_badge_stylefilter. - An empty custom text behaves like Auto.
Where to set it
- Product edit screen — the Product Badge box in the right-hand column. Saved when you click Update.
- Quick Edit — in Products → All Products, hover a product and click Quick Edit. The fields are pre-filled with the current setting.
Saving requires the permission to edit that product and a valid nonce. Data is stored as two product meta values (_badgify_override, _badgify_custom_text), read through the WooCommerce product object, so they add no extra query in normal product loops.
Matched Count
The Matched column in All Badges shows how many published products each badge is currently on, for example “12 products”. It answers “is this rule doing anything?” without browsing your catalogue.
- Click a count to refresh it instantly. Otherwise it is cached for 6 hours and cleared whenever you save a badge or change a product’s override.
- Counts respect category targeting and each variable product is counted once, not once per variation.
- Products set to Hide badge are not counted.
Display Options
Open Product Badge Rules → Display to control where badges appear.
| Option | What it does |
|---|---|
| Show on Shop / Archive | Badges on shop, category and tag pages and product loops. |
| Show on Single Product | Badge on the main product image of a single product page. Related-product loops follow the Shop / Archive setting. |
| Replace WooCommerce Sale Flash | Hides WooCommerce’s “Sale!” bubble per product, only where one of your badges (or a Hide override) takes its place. Sale products your badges don’t cover keep the theme’s own flash. |
| Show Badge Column in Product List | Adds a Badges column to Products → All Products showing the badge each product currently gets. |
| Badge Z-Index | Stacking order of badges above the product image (1–9999). |
Themes & Page Builders
Classic themes
Badges are added through the standard WooCommerce hooks woocommerce_before_shop_loop_item_title (product loops) and woocommerce_before_single_product_summary (single product). Tested with Storefront.
Block themes
Badges also render inside the WooCommerce Product Collection block and on single product pages, and the block theme’s own Sale badge block is hidden per product when one of your badges replaces it. Tested with Twenty Twenty-Five.
Page builders
Builder widgets that render the product loop through the standard WooCommerce hooks show badges. Widgets that replace the loop with fully custom markup may not — if badges are missing in a builder widget, switch to the builder’s WooCommerce-hook-based product loop or contact the builder’s support about hook compatibility.
The badge stylesheet loads on shop, category, tag and single product pages — and on any other page where a badge is actually output (for example a landing page with a Product Collection block).
Admin Screens
The plugin adds a top-level Product Badge Rules menu with five screens. Everything requires the manage_woocommerce capability (Shop Manager and Administrator), and every save is protected by a nonce.
| Screen | Purpose |
|---|---|
| Dashboard | Totals for all and active badges, display locations, a shortcut to add a badge and the list of active badges. |
| All Badges | Badge list with rule, Matched count and an on/off toggle. Add, edit and delete badges here. |
| Display | Where badges appear, sale flash replacement, product list column and z-index. |
| Rule | Global defaults for rules with an empty rule value: New Arrival days, Low Stock threshold, Hot Seller minimum sales. |
| Advanced | Badge font size. |
The badge editor
Click Add New Badge (or Edit on an existing one). The editor has Basic, Design, Position, Schedule & Priority, and Category Targeting sections, with a live preview on the right.
Products list
With Show Badge Column in Product List on, Products → All Products gains a Badges column. Quick Edit gains the Product Badge override fields.
All Settings
Global settings live in one WordPress option, badgify_settings, seeded with these defaults on first activation. Each badge itself is a row in the {prefix}badgify_badges table.
| Key | Default | Description |
|---|---|---|
| show_on_archive | 1 | Show badges on shop / archive pages and loops |
| show_on_single | 1 | Show badges on single product pages |
| replace_sale_flash | 1 | Hide the WooCommerce “Sale!” flash where a badge is shown |
| show_product_column | 1 | Add the Badges column to the product list |
| new_days | 30 | Default window for the New Arrival rule (1–365 days) |
| low_stock_threshold | 5 | Default threshold for the Low Stock rule |
| hot_min_sales | 50 | Default minimum sales for the Hot Seller rule |
| badge_z_index | 99 | CSS z-index of badges (1–9999) |
| badge_font_size | 11 | Badge text size in px (9–24) |
| max_badges | 1 | Internal. The free version always shows one badge per product |
Badge fields
| Field | Values |
|---|---|
| rule_type | sale new featured low_stock out_of_stock hot backorder price_range product_tag |
| rule_value | Number for new, low_stock, hot; min-max (e.g. 0-20, 100-) for price_range; comma-separated tag IDs for product_tag; empty otherwise |
| shape | rounded square circle ribbon |
| position | top-left top-center top-right middle-left middle-right bottom-left bottom-center bottom-right |
| category_ids | Comma-separated product category IDs (empty = every product) |
Product meta
| Meta key | Value |
|---|---|
| _badgify_override | hide or custom (absent = Auto) |
| _badgify_custom_text | Custom badge text, up to 30 characters (used with custom) |
Developer Hooks
Product Badge Rules is namespaced PHP (Badgify\…) with no global function pollution, and a few small extension points.
Filter: badgify_render_badge
Return false to stop a specific badge from rendering. Receives the default (true) and the badge object.
add_filter( 'badgify_render_badge', function ( $render, $badge ) { if ( 'hot' === $badge->rule_type && ! is_user_logged_in() ) { return false; } return $render; }, 10, 2 );
Filter: badgify_custom_badge_style
Changes the look of a Custom text badge on products where no badge rule matches. Return an array with bg_color, text_color, shape and position.
add_filter( 'badgify_custom_badge_style', function ( $style ) { $style['bg_color'] = '#5b4fff'; $style['shape'] = 'square'; return $style; } );
Filter: badgify_rule_map
Maps a rule_type slug to a rule class. A rule class extends \Badgify\Rules\Rule_Abstract and implements matches( \WC_Product $product, string $rule_value ): bool; it can also override label_tokens() to add label placeholders.
class My_Clearance_Rule extends \Badgify\Rules\Rule_Abstract { public function matches( \WC_Product $product, string $rule_value ): bool { return has_term( 'clearance', 'product_cat', $product->get_id() ); } } add_filter( 'badgify_rule_map', function ( $map ) { $map['clearance'] = My_Clearance_Rule::class; return $map; } );
Badges whose rule_type is registered through this filter are evaluated by the engine, but the badge editor lists the nine built-in rules only. Custom-rule badges have to be created in code.
Action: badgify_loaded
Fires once the plugin has finished booting (WooCommerce is active and all modules are registered). Use it to run code that depends on the plugin.
Template override
Copy templates/badge.php from the plugin folder to your-theme/badgify/badge.php. The template receives a $badge object with resolved_label, bg_color, text_color, shape and position.
CSS hooks
| Selector / variable | Meaning |
|---|---|
| .badgify-badge | Every badge element |
| .badgify-pos-{position} | Position class, e.g. badgify-pos-top-left |
| .badgify-shape-{shape} | Shape class, e.g. badgify-shape-ribbon |
| --badgify-z-index | CSS variable set from Display → Badge Z-Index |
| --badgify-font-size | CSS variable set from Advanced → Badge Font Size |
Performance & Caching
- One query for all badges. Active badges load in a single database query, kept in memory for the request and in a 12-hour transient across requests. Saving, deleting or toggling a badge clears it.
- No per-product queries. Rules are evaluated in PHP on data WooCommerce has already loaded, and per-product overrides are read from the product’s cached meta.
- No front-end JavaScript. Badges are server-rendered HTML styled by one small stylesheet.
- Conditional assets. The stylesheet loads only on WooCommerce shop, archive and product pages — or wherever a badge is actually output. Admin scripts and styles load only on the plugin’s own screens, plus a tiny script on the product edit and product list screens for the override box.
- Admin-only counts. The Matched count runs in the admin only and is cached for 6 hours.
Privacy & Data
- The plugin does not collect, store or transmit any personal data from your visitors.
- All badge logic runs on your own server using existing WooCommerce product data.
- No cookies, no external HTTP requests, no third-party services.
- Stored data: the
{prefix}badgify_badgestable, the optionsbadgify_settings,badgify_db_versionandbadgify_version, a fewbadgify_transients, and the two optional product meta keys. - Deleting the plugin via Plugins → Delete drops the table and removes all options, transients and per-product override meta. Your products, prices and orders are never touched.
Deactivating only stops badges from showing — your badges and settings are kept. Data is removed only when you delete the plugin.
Troubleshooting
A badge is not showing on a product
- Is the badge’s Status on, and is today inside its Active From / Until dates?
- Is Show on Shop / Archive (or Single Product) enabled under Display?
- Does the product match the rule? Check the rule definition in The 9 Badge Rules — for example Low Stock needs Manage stock on the product.
- If the badge has Category Targeting, is the product assigned to one of those categories directly?
- Is the product’s Product Badge box set to Hide badge?
- Is another badge with a lower priority number matching the same product? Only one badge is shown.
The badge is behind the product image
Increase Display → Badge Z-Index (try 999).
Two sale badges appear
Turn on Display → Replace WooCommerce Sale Flash. If a second bubble remains, your theme or builder draws its own sale label outside WooCommerce’s standard sale-flash hooks and needs its own setting.
The Matched count looks out of date
Click the count to recompute it immediately. Counts refresh on their own every 6 hours and whenever a badge or override is saved.
A Price Range badge doesn’t show on a product
The rule uses the product’s current price (sale price while on sale; lowest variation price for variable products). Products with no price never match.
Frequently Asked Questions
Can I show more than one badge on a product?
How do I hide the badge on one specific product?
Can I give one product its own badge text?
How do I create a “Pre-order” badge?
How do I create an “Under $20” or “Premium” badge?
20 for “Under $20”, or Min 100 (Max empty) for “Premium”. The current price is used, so a product on sale is judged by its sale price.Can I show a badge only on products with a certain tag or category?
Can I schedule a badge for a sale or holiday?
Will this slow down my store?
Does it work with variable products?
{pct} token compares the highest regular price with the lowest sale price.