Guest User

Untitled

a guest
May 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. add_filter( 'woocommerce_sale_flash2', 'lx_custom_onsale_label', 10, 2 );
  2. function lx_custom_onsale_label() {
  3. global $product;
  4.  
  5. $percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
  6. $absolute = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) ) );
  7.  
  8. if ($product->get_regular_price() > 100) {
  9. return '<span class="onsalex bg_primary headerfont">'. sprintf( __(' -%s', 'salex' ), $absolute . ',-' ).'</span>';
  10. }
  11.  
  12. else if ($product->get_regular_price() < 1) {
  13. return '<span class="onsalessszzzx bg_primary headerfont">'. sprintf( __(' -%s', 'salex' ), $absolute . ',-' ).'</span>';
  14. }
  15.  
  16. else {
  17. return '<span class="onsalexzzz bg_primary headerfont">'. sprintf( __(' -%s', 'salex' ), $percentage . '%' ).'</span>';
  18. }
  19. }
  20.  
  21. $percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
  22.  
  23. $percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
  24.  
  25. $percentage = 0;
  26. if ( $product->get_regular_price() > 0 )
  27. $percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
  28.  
  29. if ($product->get_regular_price() != 0){
  30. // Do stuff
  31. } else {
  32. // Do something with the zero
  33. }
  34.  
  35. if ($product->get_regular_price() > 0){
  36. // Do stuff
  37. } else {
  38. // Do something with the zero
  39. }
  40.  
  41. if($product->get_regular_price()> 0)
  42. {
  43. //do your work
  44. }
  45.  
  46. $var = @($val1 / $val2);
Add Comment
Please, Sign In to add comment