How to show Sale Percentage in Woocommerce

///How to show Sale Percentage in Woocommerce

You must have access to files that need to be modified to show the sale percentage in woocommerce :

Woocommerce files :

  1. -> /—/wp-content/plugins/woocommerce/templates/loop/sale-flash.php
  2. -> /—/wp-content/plugins/woocommerce/templates/single-product/sale-flash.php

Step 1 :

Find the file : sale-flash.php

Step 2 :

Open and edit the file : sale-flash.php

Step 3 :

Add this code and comment the original :


 <?php 
 
 if($product->regular_price > 0){
 $percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 );
 if($percentage < 100){
 echo apply_filters( 'woocommerce_sale_flash', '<span class="onsale">' . __( $percentage . '%', 'woocommerce' ) . '</span>', $post, $product ); 
 }
 }
 
 ?>

Do the same for both files. If you have Cache Plugins , clear the cache to see the change.

With Percentage :

Without Percentage :

By | 2017-04-13T13:33:09+00:00 February 11th, 2017|0 Comments

Leave A Comment