ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

list.php (4329B)


      1 <?php
      2 
      3 
      4 // card item template start
      5 
      6 remove_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10);
      7 
      8 remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
      9 remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5);
     10 
     11 
     12 function materialis_woocommerce_before_shop_loop_item()
     13 {
     14     $class = apply_filters('materialis_woocommerce_archive_item_class', array());
     15     $class = implode(' ', array_unique($class));
     16     ?>
     17 
     18     <div class="ope-woo-card-item <?php echo esc_attr($class); ?>">
     19 
     20     <?php
     21 }
     22 
     23 // start card item
     24 add_action('woocommerce_before_shop_loop_item', 'materialis_woocommerce_before_shop_loop_item', 0);
     25 add_action('woocommerce_before_subcategory', 'materialis_woocommerce_before_shop_loop_item', 0);
     26 
     27 
     28 // start header
     29 add_action('woocommerce_before_shop_loop_item_title', function(){
     30     ?>
     31     <div class="ope-woo-card-header">
     32     <?php
     33 }, 0);
     34 
     35 
     36 //end header
     37 add_action('woocommerce_before_shop_loop_item_title', function(){
     38     ?>
     39     </div>
     40     <?php
     41 }, PHP_INT_MAX);
     42 
     43 
     44 // start content
     45 add_action('woocommerce_shop_loop_item_title', function(){
     46     ?>
     47     <div class="ope-woo-card-content">
     48     <?php
     49 }, 0);
     50 
     51 
     52 //end content
     53 add_action('woocommerce_shop_loop_item_title', function(){
     54     ?>
     55     </div>
     56     <?php
     57 }, PHP_INT_MAX);
     58 
     59 
     60 // start footer section
     61 add_action('woocommerce_after_shop_loop_item', function () {
     62     ?>
     63     <div class="ope-woo-card-footer">
     64 
     65     <?php
     66 }, 0);
     67 
     68 
     69 // end footer section
     70 add_action('woocommerce_after_shop_loop_item', function () {
     71     ?>
     72     </div>
     73     <?php
     74 }, PHP_INT_MAX);
     75 
     76 
     77 // end card item
     78 add_action('woocommerce_after_shop_loop_item', function () {
     79     ?>
     80     </div>
     81     <?php
     82 }, PHP_INT_MAX);
     83 
     84 add_action('woocommerce_after_subcategory', function () {
     85     ?>
     86     </div>
     87     <?php
     88 }, PHP_INT_MAX);
     89 
     90 
     91 // card item template end
     92 
     93 
     94 //card item content
     95 
     96 function materialis_woocommerce_product_list_print_categories()
     97 {
     98     global $product;
     99     ?>
    100     <div class="ope-woo-card-content-section ope-woo-card-content-categories">
    101         <?php echo wc_get_product_category_list($product->get_id()); ?>
    102     </div>
    103     <?php
    104 }
    105 
    106 function materialis_woocommerce_product_list_print_title()
    107 {
    108     ?>
    109     <div class="ope-woo-card-content-section ope-woo-card-content-title">
    110         <h3 class="ope-card-product-tile"><?php the_title() ?></h3>
    111     </div>
    112     <?php
    113 }
    114 
    115 function materialis_woocommerce_product_list_print_rating()
    116 {
    117     ?>
    118     <div class="ope-woo-card-content-section ope-woo-card-content-rating">
    119         <?php woocommerce_template_loop_rating() ?>
    120     </div>
    121 
    122     <?php
    123 }
    124 
    125 function materialis_woocommerce_product_list_print_price()
    126 {
    127     ?>
    128     <div class="ope-woo-card-content-section ope-woo-card-content-price">
    129         <?php woocommerce_template_loop_price() ?>
    130     </div>
    131     <?php
    132 }
    133 
    134 function materialis_woocommerce_product_list_print_description()
    135 {
    136     $description_in_archive_only = get_theme_mod('materialis_woocommerce_description_in_archive_only', true);
    137 
    138     if ( ! is_archive() && intval($description_in_archive_only)) {
    139         return;
    140     }
    141 
    142     ?>
    143     <div class="ope-woo-card-content-section ope-woo-card-content-description">
    144         <?php the_excerpt() ?>
    145     </div>
    146     <?php
    147 }
    148 
    149 
    150 function materialis_woocommerce_card_item_get_print_order()
    151 {
    152 
    153     $order  = get_theme_mod('woocommerce_card_item_get_print_order', false);
    154     $result = array();
    155 
    156     if ($order === false) {
    157         $result = array('title', 'rating', 'price', 'categories');
    158     } else {
    159         $result = $order;
    160     }
    161 
    162 
    163     return $result;
    164 }
    165 
    166 
    167 add_action('woocommerce_shop_loop_item_title', function () {
    168     $toPrint = materialis_woocommerce_card_item_get_print_order();
    169 
    170     foreach ($toPrint as $item) {
    171         if (function_exists("materialis_woocommerce_product_list_print_{$item}")) {
    172             call_user_func("materialis_woocommerce_product_list_print_{$item}");
    173         }
    174 
    175     }
    176 });
    177 
    178 
    179 add_filter('woocommerce_product_loop_start', function ($loop_html) {
    180     $display_type = woocommerce_get_loop_display_mode();
    181 
    182     // If displaying categories, append to the loop.
    183     if ('subcategories' === $display_type || 'both' === $display_type) {
    184 
    185         $loop_html .='<li class="col-xs-12 col-sm-12 space-bottom space-top"></li>';
    186 
    187     }
    188 
    189     return $loop_html;
    190 }, 20);