Search by

infrangible / m2-catalog-product-badge

infrangible

Shows New, Sale and Sold Out badges on the product images of product lists and product pages, with the discount in percent if wanted.

Package info

github.com/infrangible-dev/m2-catalog-product-badge

Homepage

Type:magento2-module

pkg:composer/infrangible/m2-catalog-product-badge

Statistics

Installs: 14

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.1.0 2026-11-30 21:26 UTC

This package is auto-updated.

Last update: 2026-11-30 21:28:11 UTC


README

Shows the badges New, Sale and Sold Out on the product images of product lists (categories, search results and product list widgets) and on the main image of the product page. The Sale badge can show the discount in percent, for example "-20%".

Badges

  • New: while today is within "Set Product as New from" and "to" of the product (one of both is enough).
  • Sale: if the final price is lower than the regular price, with special prices, catalog price rules and tier prices for one piece, for the website and customer group of the customer. The prices come from Magento's price index, so configurable products get the badge if one of their variants has a discount.
  • Sold Out: if the product cannot be bought. Out of stock products are only listed if "Display Out of Stock Products" is enabled (Stores > Configuration > Catalog > Inventory > Stock Options).

Discount in percent

The Sale badge shows either its text or the discount in percent, set per store view. The percentage is only shown if all prices of the product have the same discount, for example all variants of a configurable product; otherwise the text is shown.

Look

The badges are shown in a corner of the image. Text, corner, shape, text color and background color are set per badge and store view. The shapes:

  • Label (default): the text on the background color, a small rectangle.
  • Ribbon: the text on a band in the background color, with swallowtail ends behind it in a darker shade of the background color, folded below the band.
  • Stamp: the text in a rounded frame in the text color, on the background color, with a shadow and turned a little, like a sticker. A white background and a red text make it look like a stamp.

The badges of the same corner are shown below each other. On the product page, the thumbnails are below the image, so badges of the lower corners are shown in the upper corners there.

Themes can change the look with CSS (classes infrangible-badge, infrangible-badge-new, -sale, -sold_out and infrangible-badge-shape-label, -ribbon, -stamp) or override the template Infrangible_CatalogProductBadge::badges.phtml. The sizes of the shapes are LESS variables in view/frontend/web/css/source/_module.less (@infrangible-badge-ribbon__*, @infrangible-badge-stamp__*), which a theme can set again in its Infrangible_CatalogProductBadge/web/css/source/_extend.less, for example a bold font for the stamp if the font of the theme has none: @infrangible-badge-stamp__font-family: 'Open Sans', sans-serif;. The texts of the badges can be translated like other texts of the store.

Full page cache

Magento does not clean cached pages when a "new from/to" date or a special price date is reached. The module limits the cache lifetime of pages and product list widgets with badges to the next such date, for the built-in full page cache and for Varnish.

Configuration

Stores > Configuration > Infrangible Solutions > Product Badges, with a group per badge: Enable, Text, Position, Shape, Text Color, Background Color, and for Sale also Show (Text or Discount in Percent). All badges are enabled by default.

Requirements

  • Magento Open Source or Adobe Commerce 2.4.6 or newer
  • PHP 8.1 or newer
  • The Luma theme or a theme based on it; a Hyvä version will follow as a separate module

Installation

composer require infrangible/m2-catalog-product-badge
bin/magento module:enable Infrangible_CatalogProductBadge
bin/magento setup:upgrade
bin/magento cache:flush

In production mode, also run bin/magento setup:di:compile and bin/magento setup:static-content:deploy.

License

Infrangible Product Badges is licensed under the MIT License - see the LICENSE file for details.