Skip to main content

Product Badges

Product Badges

The labels on a product: its discount, and whichever others you turn on — out of stock, on backorder, featured. Each one has its own group in the panel, with a switch, its text and its two colours.

The discount is worked out from the prices and rounded to the nearest whole number, the same way the cart and the checkout round the «−20%» they print on each line, so the card and the cart never disagree about one product. When the variations are discounted by different amounts — or some are and some are not — it says «Up to −30%»: a plain figure would claim every one of them is 30% off. Empty the «Up to» text to show the largest figure with no prefix.

A badge shows when the product has it and its switch is on; when none applies, the component takes no room at all, so a card without badges is not left with a gap. In the builder every badge that is switched on shows, whatever the product being previewed, so there is always one to click and style.

Props

PropTypeDefaultWhat it does
Discount → Show iton / offon
Discount → «Up to» texttext{this.fecommerce.badge_up_to_label}Only shown when the variations are discounted by different amounts — «Up to −30%» — because a plain figure would claim every one of them is 30% off. Empty it to show the largest figure with no prefix.
Discount → Before the figuretext−The minus sign by default, not a hyphen: WordPress turns a lone hyphen into a dash, «–20%», and this one it leaves alone. The cart and the checkout print the same. Write «Save » to read «Save 30%».
Discount → After the figuretext%Write «% off» to read «30% off».
Discount → Backgroundtext#b91c1cRed on its own account, like the sale price: a convention, not a state, so changing the colour of your error messages does not repaint every sale.
Discount → Texttext#ffffff
Out of stock → Show iton / offon
Out of stock → Texttext{this.fecommerce.badge_out_of_stock_label}
Out of stock → Backgroundtextvar(--fe-woo-muted, #6b7280)Greyed, which is what «not available» looks like, with the surface as the text — the pair «Design» already checks as muted text on the surface, so it contrasts in any palette the shop has passed.
Out of stock → Text colourtextvar(--fe-woo-surface, #ffffff)
On backorder → Show iton / offoffNever together with «Out of stock»: a product on backorder can be bought, and telling a shopper it is sold out loses the sale.
On backorder → Texttext{this.fecommerce.badge_backorder_label}
On backorder → Backgroundtextvar(--fe-woo-warning-soft, #fef3c7)
On backorder → Text colourtextvar(--fe-woo-warning, #b45309)
Featured → Show iton / offoffThe products marked with the star in WooCommerce’s product list.
Featured → Texttext{this.fecommerce.badge_featured_label}
Featured → Backgroundtextvar(--fe-woo-accent, #111827)The brand’s own pair, the one every button is read in — so its contrast is whatever the shop already checked in «Design».
Featured → Text colourtextvar(--fe-woo-accent-color, #ffffff)
Badge style → Text sizetextvar(--fe-woo-text-xs, 0.75rem)
Badge style → Weighttext600
Badge style → Paddingtext0.25rem 0.5rem
Badge style → Corner radiustextvar(--fe-woo-control-radius, 0.5rem)Follows the shop’s buttons by default, so pill buttons make pill badges. 999px makes them pills on their own.
Layout → Directionchoice: row, columnrowStacked is the usual corner of a product photo.
Layout → Alignmentchoice: flex-start, center, flex-endflex-startAlong the line when side by side; to one side when stacked. «End» with «Stacked» puts them in the right-hand corner.
Layout → Gaptext0.38rem
Product badgestext{this.fecommerce.badge_flags}Which badges this product has, as words: «discount out-of-stock». Inside a loop it follows each product by itself when the loop’s item is called «this»; with any other name, bind it to that name.
Discounttext{this.fecommerce.discount_percent_text}The figure alone, without the sign. In a loop, the same as the one above.

Variables of its own

VariableDefaultWhat it controls
--fe-woo-badges-discount-bg#b91c1cThe discount badge. Red on its own account, like the sale price: a convention, not a state, so changing «Error» does not repaint every sale.
--fe-woo-badges-discount-color#ffffffIts text.
--fe-woo-badges-out-of-stock-bgvar(--fe-woo-muted, #6b7280)Out of stock: greyed, which is what «not available» looks like. The pair «Design» already checks as muted text on the surface.
--fe-woo-badges-out-of-stock-colorvar(--fe-woo-surface, #ffffff)Its text.
--fe-woo-badges-backorder-bgvar(--fe-woo-warning-soft, #fef3c7)On backorder: can be bought, will take longer — the warning pair the account’s order badges use.
--fe-woo-badges-backorder-colorvar(--fe-woo-warning, #b45309)Its text.
--fe-woo-badges-featured-bgvar(--fe-woo-accent, #111827)Featured: the brand’s own pair, the one every button is read in.
--fe-woo-badges-featured-colorvar(--fe-woo-accent-color, #ffffff)Its text.
--fe-woo-badges-sizevar(--fe-woo-text-xs, 0.75rem)The text of every badge.
--fe-woo-badges-weight600Its weight.
--fe-woo-badges-padding0.25rem 0.5remThe room inside each badge.
--fe-woo-badges-directionrowrow side by side, column stacked — the usual corner of a product photo.
--fe-woo-badges-alignflex-startWhere they sit: along the line when side by side, to one side when stacked. Each value means the same in both.