paolo_bortolotti

Untitled

Sep 3rd, 2021
1,089
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-------------ADD TO CART -----------------
  2.  
  3. <?php
  4.    
  5. global $product;
  6. if (!isset($product) || !$product) {return;}
  7.  
  8.  
  9. $StockQ=$product->get_stock_quantity();
  10.  
  11.  if ($StockQ>=0 && $product->is_in_stock() ){
  12. echo do_shortcode('[add_to_cart id="'. $product->get_id() . '"]');
  13.  }
  14.  
  15. ?>
  16.  
  17. //----------------SALES BADGE -------------
  18.  
  19. <?php
  20.  
  21. global $product;
  22. if (!isset($product) || !$product) {return;}
  23.  
  24. if ( $product->is_on_sale() )  {
  25.  
  26. ?> <div id="c_sales_badge" class="custom-sales-badge" ><h6 >SALE!</h6></div> <?php
  27.                                
  28.      }
  29.  
  30.  
  31. ?>
  32.  
  33.  
  34.  
  35. //-----------DISCOUNT PERCENT  (activate relevant code snippet for this to work) ----------------
  36.  
  37. <?php
  38.     echo show_sale_percentage_loop()
  39. ?>
  40.  
  41.  
  42.  
  43. //-------------- QUICK VIEW ----------------
  44.  
  45. <?php
  46.    
  47. global $product;
  48. if (!isset($product) || !$product) {return;}
  49.  
  50. $pId = $product->get_id();
  51.  
  52. echo do_shortcode('[woosq id="'. $pId . '"]');
  53.  
  54. ?>
  55.  
  56.  
  57.  
  58. //------------- OUT OF STOCK --------------
  59.  
  60. <?php
  61.     global $product;
  62. if (!isset($product) || !$product) {return;}
  63.  
  64. $StockQ=$product->get_stock_quantity();
  65.  
  66.     if ($StockQ<1 && ! $product->is_in_stock() ){
  67.     echo '<div id="c_out_stock_badge" class="custom-out-of-stock-badge" ><h6 >OUT OF STOCK</h6></div>';
  68.     }
  69.  
  70.  
  71. ?>
  72.  
  73.  
  74.  
RAW Paste Data