Archive | Snippets & Tips

RSS feed for this section

WooCommerce Number Of Products Sold

A question that has been popping up quite a lot lately in the WooCommerce support forums is how do I display the total amount of units sold for a product on the product page. In this WooCommerce tutorial I will be showing you how to display this on the product page.

Luckily WooCommerce already takes care of the majority of work for us to do this as it automatically keeps track of the number of units sold for each product for reporting purpose, all we have to do it do retrieve the value and display it on the product page.

To display the number of units sold for a product add the following snippet of code to your theme’s functions.php file

 

add_action( 'woocommerce_single_product_summary', 'wc_product_sold_count', 11 );
function wc_product_sold_count() {
	global $product;
	$units_sold = get_post_meta( $product->id, 'total_sales', true );
	echo '<p>' . sprintf( __( 'Units Sold: %s', 'woocommerce' ), $units_sold ) . '</p>';

}

This will result in the Units Sold text to display underneath the product title and price.

WooCommerce_units_sold

You may also change the display text labeled Units Sold: to anything else you like.

woosnippet

How to: Remove WooThemes and/or IgniteWoo Updater Plugin Notice

If you’ve installed any WooCommerce plugins or themes by WooThemes (or any IgniteWoo product) that didn’t come with the automatic updates you get from WooThemes, you’ve likely seen this annoying little notification urging you to get the WooTheme Updater plugin so you can receive automatic updates.

woothemes updater

Here we show you how to remove it.

If there’s one thing that ticks me us it’s plugins that add notices to your WordPress admin area that cannot be dismissed.

WooThemes and IgniteWoo do it with a lot of their extensions including WooCommerce essentially advertising their updater plugin.

To remove WooThemes and IgniteWoo update plugin notices, add the following code to your theme’s functions.php file:

//Remove WooThemes Updater
remove_action('admin_notices', 'woothemes_updater_notice');
//Remove IgniteWoo Updater
remove_action('admin_notices', 'ignitewoo_updater_notice');