Scheduling sales and showing Countdowns or Limited sale badge

Estimated reading time: 1 min

First thing you’ll need to do is to set a scheduled sale inside each product you want to show these badges


Showing the badge inside products in Catalog or Product page:

Please head over to Settings › WooCommerce › Catalog › Product Card › Scheduled Sales and locate the options eg: screenshot .

You can change its layout as Countdown eg: screenshot or Text Badge eg: screenshot and relocate it elsewhere inside the product or customize its colors.

For product pages display, simply access Settings › WooCommerce › Product Page › Summary Components › Scheduled Sale and you will find pretty much the exact same settings but dedicated to the product page.

Making a sale Evergreen

If you want to display a permanent sale badge or countdown to a particular product (regardless if the Scheduled Sale expired) you should be able to find the options in every product’s backend ex: screenshot .

Overriding some parameters by small code snippets

You can copy these codes below and paste them inside the child theme’s functions.php to override some internal parameters.

Changing texts

You can use this filter below to override the texts in the badge or countdown. A better way of doing this though is by using Loco Translate plugin. If the texts don’t show up, make sure to Sync first.

add_filter('reycore/woocommerce/scheduled_sales/defaults', function( $defaults ){
	$defaults['strings'] = [
		'm' => [
			'singular' => 'month',
			'plural' => 'months',
			'abbr' => 'mon.',
		],
		'd' => [
			'singular' => 'day',
			'plural' => 'days',
		],
		'h' => [
			'singular' => 'hour',
			'plural' => 'hours',
		],
		'i' => [
			'singular' => 'minute',
			'plural' => 'minutes',
			'abbr' => 'min.',
		],
		's' => [
			'singular' => 'second',
			'plural' => 'seconds',
			'abbr' => 'sec.',
		],
	];
	return $defaults;
});

Other settings

Each setting has a description. If you don’t want to change it, just remove it from the filter.

add_filter('reycore/woocommerce/scheduled_sales/defaults', function( $defaults ){
	/**
	 * Hides for out of stock products.
	 * Defaults to true.
	 */
	$defaults['hide_out_of_stock'] = true;
	/**
	 * Text badge uses abbreviation rather then full texts (eg: mon. instead of month)
	 * Defaults to false.
	 */
	$defaults['badge_use_short'] = false;
	/**
	 * Countdown uses abbreviations (eg: mon. instead of month)
	 * Defaults to true.
	 */
	$defaults['countdown_use_short'] = true;
	/**
	 * Text badge displays an icon
	 * Defaults to true.
	 */
	$defaults['badge_use_icon'] = true;
	/**
	 * Override the icon by providing a valid SVG markup
	 */
	$defaults['badge_icon'] = '<svg class="rey-icon" width="100%" height="100%" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M7.72461 0.0374277C7.48398 0.0131834 7.24229 0.0011146 7.00048 0.00122141H6.99322C6.59303 0.00784321 6.27305 0.335943 6.27646 0.736241V3.62164C6.2755 3.71883 6.29526 3.81506 6.33435 3.90402C6.45963 4.20222 6.76808 4.38058 7.08892 4.34053C7.45952 4.28499 7.73145 3.96341 7.72461 3.58885V1.49764C10.4284 1.85255 12.4746 4.11806 12.553 6.844C12.6314 9.56993 10.7189 11.9494 8.04 12.4591C5.36105 12.9688 2.70838 11.458 1.78026 8.89376C0.852143 6.32953 1.92317 3.47083 4.30776 2.14775C4.62475 1.96822 4.7574 1.57988 4.61642 1.24398L4.61557 1.24195C4.53653 1.05088 4.37975 0.902747 4.18451 0.8345C3.98938 0.76636 3.77439 0.78473 3.59357 0.884911C0.576484 2.56599 -0.763363 6.19656 0.43828 9.43451C1.63982 12.6726 5.02377 14.5501 8.40708 13.8559C11.7904 13.1618 14.1617 10.1036 13.9913 6.65399C13.8209 3.20446 11.1598 0.394791 7.72461 0.0374277Z" fill="currentColor"/> <path d="M4.35554 4.67456C4.64679 5.44151 5.59969 7.25235 6.31249 8.02336C6.7507 8.51807 7.49896 8.58429 8.01728 8.17438C8.27659 7.95682 8.43263 7.64047 8.44759 7.30234C8.46243 6.9643 8.33459 6.63546 8.09546 6.39601C7.34997 5.65063 5.45796 4.66302 4.66463 4.36184C4.57577 4.32841 4.47548 4.35041 4.40862 4.41791C4.34187 4.48552 4.32104 4.58602 4.35554 4.67456Z" fill="currentColor"/> </svg>';
	return $defaults;
});
Show comments and replies (closed)Hide comments and replies

Left here in 2021, when comments were open. The answers were written then and may describe a version of Rey that has changed since.

  1. Aenyeone

    Hello,
    just to point out that the text "days" of the text badge is not translatable with for example loco Translate, neither in the child theme, nor in the core.

  2. MariusRey

    Hey!

    It should be translatable with Loco Translate, but before searching these strings, make sure to click the Sync button in Loco Translate's bar (near the search field).

    I also updated the article with some code snippets to be able to override or change some internal parameters.

Was this article helpful?