Skip Navigation

[Resolved] WooCommerce "Sale" field? Where is it?

This support ticket is created 10 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 -
- - - - - - -

Supporter timezone: Europe/Madrid (GMT+01:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Jive 10 years, 1 month ago.

Assigned support staff: Caridad.

Author
Posts
#33999

I have my WooCommerce shop somewhat close to completion. I'm struggling to find a way to put the "Sale" badge in my product View.

Is there a shortcode for just the on sale badge?

I've attached a screenshot of the demo page for Woo's Canvas theme (I'm using Genesis) to show you what i'm talking about. It's the little red, oval "Sale" badge for the products that are on sale.

My current View code is this, if it matters:

[wpv-layout-start]
<!-- wpv-loop-start -->
   <wpv-loop>
<li class="product"><h3>[wpv-post-link]</h3>
	<span class="price">
	    [wpv-if price="_sale_price" evaluate="empty($price)"]
	    [wpv-if price="_min_variation_price" evaluate="empty($price)"]
	        $[wpv-post-field name="_price"]
	    [/wpv-if]
	    [/wpv-if]
	    [wpv-if price="_sale_price" evaluate="!empty($price)"]
		    <del>$[wpv-post-field name="_regular_price"]</del> $[wpv-post-field name="_sale_price"]
	    [/wpv-if]    
	    [wpv-if price="_min_variation_sale_price" evaluate="!empty($price)"]
		    From: <del>$[wpv-post-field name="_min_variation_regular_price"]</del> $[wpv-post-field name="_min_variation_sale_price"]
		[/wpv-if]    
	    [wpv-if price="_min_variation_price" evaluate="!empty($price)"]
		    From: $[wpv-post-field name="_min_variation_price"]
	    [/wpv-if]
</span>
	[wp_media media="audio" volume=0.8 urls="[types field="file"][/types]"]
	<span class="product-meta"><p><i class="icon-folder-close-alt"></i> [wpv-post-taxonomy type="product_cat" separator=", " format="link" show="name"]</p><p><i class="icon-headphones"></i> [wpv-post-taxonomy type="producers" separator=", " format="link" show="name"]</p></span>
[wpv-wooaddcart]
<div class="clear"></div></li>
   </wpv-loop>
<!-- wpv-loop-end -->
[wpv-no-posts-found][wpml-string context="wpv-views"]<strong>No posts found</strong>[/wpml-string][/wpv-no-posts-found]
[wpv-layout-end]

This code is working perfectly for the way I want my shop to look, the only thing missing on the product archives is the Sale badge.

#34089

Dear Jive,

You can evaluate if the sale price is not empty and show the badge in its proper location:

[wpv-if sale="_sale_price" evaluate="!empty($sale)"]
<span class="onsale">Sale!</span>
[/wpv-if]

Please let me know if there is anything else that I can assist you with.

Regards,
Caridad

#34101

I'm embarrassed at how obvious that was. I forgot the sale badge was just a simple span class, I was thinking it was more functionality and required it's own dedicated shortcode.
Thank you!