Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'woocommerce_sale_flash2', 'lx_custom_onsale_label', 10, 2 );
- function lx_custom_onsale_label() {
- global $product;
- $percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
- $absolute = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) ) );
- if ($product->get_regular_price() > 100) {
- return '<span class="onsalex bg_primary headerfont">'. sprintf( __(' -%s', 'salex' ), $absolute . ',-' ).'</span>';
- }
- else if ($product->get_regular_price() < 1) {
- return '<span class="onsalessszzzx bg_primary headerfont">'. sprintf( __(' -%s', 'salex' ), $absolute . ',-' ).'</span>';
- }
- else {
- return '<span class="onsalexzzz bg_primary headerfont">'. sprintf( __(' -%s', 'salex' ), $percentage . '%' ).'</span>';
- }
- }
- $percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
- $percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
- $percentage = 0;
- if ( $product->get_regular_price() > 0 )
- $percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
- if ($product->get_regular_price() != 0){
- // Do stuff
- } else {
- // Do something with the zero
- }
- if ($product->get_regular_price() > 0){
- // Do stuff
- } else {
- // Do something with the zero
- }
- if($product->get_regular_price()> 0)
- {
- //do your work
- }
- $var = @($val1 / $val2);
Add Comment
Please, Sign In to add comment