Guest User

Product list in WooCommerce

a guest
Jul 26th, 2020
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.79 KB | None | 0 0
  1. <?php
  2.     $available_variations = $product->get_available_variations();
  3.     foreach ($available_variations as $value)
  4.     {
  5.     $term = get_term_by('slug', $value["attributes"]["attribute_vozrast"], 'vozrast');
  6.     $t = $term->name;
  7.     if ($value["max_quantity"] == 0) {
  8.         $cl='disabled_product';
  9.     }
  10.     else {
  11.         $cl='';
  12.     }
  13.     if ($value["max_quantity"] == 0) {
  14.         $bcl = 'gray';
  15.     }
  16.     else {
  17.         $bcl = 'orange';
  18.     }
  19.     ?>
  20.     <form class="feel-product-variable-loop cart" method="post" enctype="multipart/form-data"> 
  21.         <div class="feel-product-parameters_row-data <?php echo $cl; ?>">
  22.             <div class="feel-product-years-data">
  23.                 <span class="feel-product-years-name"><span><?php echo $t; ?></span>
  24.                     <?php if ( $value["max_quantity"] <= 10 ) {?>
  25.                         <div class="how-much-in-storage">
  26.                             В наличии лишь: <?php echo $value["max_quantity"];?>
  27.                         </div>
  28.                     <?php } ?>
  29.                 </span>
  30.             </div>
  31.             <div class="feel-product-cost-data">
  32.     <?php if ( $value["display_price"] == $value["display_regular_price"] ) {
  33.        
  34.     ?>
  35.                 <span class="price"><?php echo $value["display_price"]?><i class="fa fa-rub" aria-hidden="true"></i></span>
  36.     <?}
  37.     else {
  38.     ?>
  39.  
  40.                 <span class="price"><?php echo $value["display_price"]?><i class="fa fa-rub" aria-hidden="true"></i></span>
  41.                 <span class="oldprice"><?php echo $value["display_regular_price"]?><i class="fa fa-rub" aria-hidden="true"></i></span>';
  42.     <?php
  43.     }  
  44.     ?>
  45.             </div>
  46.            
  47.                
  48.                 <div class="card_item_count_and_add">
  49.                     <div class="card-item__count">     
  50.                         <div class="quantity">
  51.                             <input type="button" value="-" class="minus">
  52.                             <label class="screen-reader-text" for="quantity_<?php echo esc_attr( $value["variation_id"] ); ?>">Quantity</label>
  53.                             <input type="number" id="quantity_<?php echo esc_attr( $value["variation_id"] ); ?>" class="input-text qty text" step="1" min="1" max="<?php echo $value["max_quantity"]; ?>" name="quantity" value="1" title="Кол-во" size="4" pattern="[0-9]*" inputmode="numeric">
  54.                             <input type="button" value="+" class="plus">
  55.                         </div>
  56.                         <button type="submit" name="add-to-cart" data-product_id="<?php echo $value["variation_id"]; ?>" class="pseudo-add-to-cart-button button alt ajax_add_to_cart1 add_to_cart_button single_add_to_cart_button"><i class="fa fa-shopping-basket"></i></button>
  57.                         <a href="https://site.ru/cart/" class="added_to_cart wc-forward" title="View cart">View cart</a>
  58.                         <input type="hidden" name="add-to-cart" value="<?php echo esc_attr( get_the_ID() ); ?>">
  59.                         <input type="hidden" name="product_id" value="<?php echo esc_attr( get_the_ID() ); ?>">
  60.                         <input type="hidden" name="variation_id" class="variation_id" value="<?php echo esc_attr( $value["variation_id"] ); ?>">
  61.                     </div>
  62.                
  63.                 </div>
  64.            
  65.            
  66.         </div>
  67.         </form>
  68.       <?php
  69. }
  70. ?>
  71.    
Advertisement
Add Comment
Please, Sign In to add comment