This plugin hasn’t been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

WooCommerce Smart Sale Badge

Description

“WooCommerce Smart Sale Badge” enhances the built-in sale badge by displaying the total saving amount a customer will receive. The plugin works with all the WooCommerce product types – simple and external products will display a badge that says ‘Save $X!’, while variable and grouped products will display ‘Save up to $X!’.

This plugin is WooCommerce 2.x and WPML compatible.

If you would like a more fully featured sale badge enhancement extension then be sure to check out Sale Flash Pro available for purchase from the WooThemes website: http://www.woothemes.com/products/sale-flash-pro/ (Sale Flash Pro was not written by me, but because WooCommerce Smart Sale Badge contains a limited feature set of Sale Flash Pro I will not be adding further features to this plugin).

Usage

Simply install and activate the plugin and you’ll be good to go.

Screenshots

  • The difference between the default and modified sale badges for simple & external products as displayed in the Twenty Twelve theme.

Installation

Installing “WooCommerce Smart Sale Badge” can be done either by searching for “WooCommerce Smart Sale Badge” via the “Plugins > Add New” screen in your WordPress dashboard, or by using the following steps:

  1. Download the plugin via WordPress.org
  2. Upload the ZIP file through the ‘Plugins > Add New > Upload’ screen in your WordPress dashboard
  3. Activate the plugin through the ‘Plugins’ menu in WordPress

FAQ

How do I edit/translate the text that appears on the badge?

You can edit or translate the text displayed on the badge using the CodeStyling Localization plugin for WordPress.

My sale badge isn’t displaying correctly – what gives!?

This plugin does not create the sale badge – that work is done by WooCommerce itself and your theme will handle the styling of the badge. All this plugin does is modify the text that appears on the badge, so if your display is wrong then the issue will be related to your theme and not this plugin.

Reviews

sales badge in percent

this plugin is great! i made small mod to show sale in percent:

<?php

if ( ! defined( 'ABSPATH' ) ) exit;

class WooCommerce_Smart_Sale_Badge {
	private $dir;
	private $file;

	public function __construct( $file ) {
		$this->dir = dirname( $file );
		$this->file = $file;

		// Handle localisation
		$this->load_plugin_textdomain();
		add_action( 'init', array( &$this, 'load_localisation' ), 0 );

		add_filter( 'woocommerce_sale_flash', array( &$this, 'badge_sale_amount' ), 10, 3 );
	}

	public function badge_sale_amount( $message, $post, $product ) {

		$saving_amount = 0;

		if ( $product->has_child() ) {

			// Loop through children if this is a variable product
			foreach ( $product->get_children() as $child_id ) {

				$regular_price = get_post_meta( $child_id, '_regular_price', true );
				$sale_price = get_post_meta( $child_id, '_sale_price', true );

				if( $regular_price != '' && $sale_price != '' && $regular_price > $sale_price ) {
					$new_saving_amount = $regular_price - $sale_price;

					// Only display the largest saving amount
					if( $new_saving_amount > $saving_amount ) {
						$saving_amount = $new_saving_amount;
					}
				}

			}

			$button_text = apply_filters("wc_smart_sale_badge_title", __( 'Do', 'wc_smart_sale_badge' ), $product->has_child(), $product);

		} else {

			// Fetch prices for simple products
			$regular_price = get_post_meta( $post->ID, '_regular_price', true );
			$sale_price = get_post_meta( $post->ID, '_sale_price', true );

			if( $regular_price != '' && $sale_price != '' && $regular_price > $sale_price ) {
				$saving_amount = $regular_price - $sale_price;
			}

			$button_text = apply_filters("wc_smart_sale_badge_title", __( '', 'wc_smart_sale_badge' ), $product->has_child(), $product);

		}

		// Only modify badge if saving amount is larger than 0
		if( $saving_amount > 0 ) {
			$saving_price = woocommerce_price( $saving_amount );
			$percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 );
			$saving_price_r = apply_filters("wc_smart_sale_badge_price", sprintf( __( ' %s!', 'wc_smart_sale_badge' ), $saving_price ), $saving_price, $product);
			$message = '<span class="onsale">' . $button_text .'-'. $percentage .'%'. '</span>';
		}

		return $message;
	}

	public function load_localisation() {
		load_plugin_textdomain( 'wc_smart_sale_badge' , false , dirname( plugin_basename( $this->file ) ) . '/lang/' );
	}

	public function load_plugin_textdomain() {
	    $domain = 'wc_smart_sale_badge';

	    $locale = apply_filters( 'plugin_locale' , get_locale() , $domain );

	    load_textdomain( $domain , WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' );
	    load_plugin_textdomain( $domain , FALSE , dirname( plugin_basename( $this->file ) ) . '/lang/' );
	}

}
Read all 5 reviews

Contributors & Developers

“WooCommerce Smart Sale Badge” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.1

  • 2014-04-15
  • [NEW] Adding wc_smart_sale_badge_title and wc_smart_sale_badge_price filters. Props @danmorton.
  • [NEW] Adding Russian translation. Props @advokatb.
  • [NEW] Adding localisation template file.

1.0

  • 2013-05-10
  • Initial release!