There is always a situation when your customers will ask you whether the product sales price has a limited period. This always happen especially for a “Last Minute Sale”, “Christmas Eve Sale” or “Holiday Sale”.

In current WooCommerce product page, you mostly will see the strikethrough for normal price and beside will have the sales price. That’s it.

Normal Sales Price Layout for WooCommerce Product Page

Normal Sales Price Layout for WooCommerce Product Page

So in this tutorial, i will teach you all a simple way to add “Offer till [date end]” text beside the sales price. You can also change the text without any effort.

Let’s begin.

Step 1: Open functions.php file in your theme folder, add below code:

add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 );
function custom_price_html( $price, $product ){
	global $post;
	$sales_price_to = get_post_meta($post->ID, '_sale_price_dates_to', true);
	if(is_single() && $sales_price_to != "")
	{
		$sales_price_date_to = date("j M y", $sales_price_to);

		return str_replace( '</ins>', ' </ins> <b>(Offer till '.$sales_price_date_to.')</b>', $price );
	}
	else
	{
		return apply_filters( 'woocommerce_get_price', $price );
	}
}

Step 2: Save the file. If you want to change the text for above example, just change “Offer till” phrase to whatever you want, ok.


Step 3: Done, refresh your product page that has ongoing sales that you have schedule start and end date.

Add Price Sales End Date at WooCommerce Product Page

Add Price Sales End Date at WooCommerce Product Page

Thanks and i will always give you little tips to help you along the way, cheers!