Advertisement
Konark

Untitled

May 26th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.59 KB | None | 0 0
  1. <?php
  2. /**
  3.  * The template for displaying product content within loops
  4.  *
  5.  * This template can be overridden by copying it to yourtheme/woocommerce/content-product.php.
  6.  *
  7.  * HOWEVER, on occasion WooCommerce will need to update template files and you
  8.  * (the theme developer) will need to copy the new files to your theme to
  9.  * maintain compatibility. We try to do this as little as possible, but it does
  10.  * happen. When this occurs the version of the template file will be bumped and
  11.  * the readme will list any important changes.
  12.  *
  13.  * @see     https://docs.woocommerce.com/document/template-structure/
  14.  * @author  WooThemes
  15.  * @package WooCommerce/Templates
  16.  * @version 3.0.0
  17.  */
  18.  
  19. if ( ! defined( 'ABSPATH' ) ) {
  20.     exit; // Exit if accessed directly
  21. }
  22.  
  23. global $product;
  24.  
  25. // Ensure visibility
  26. if ( empty( $product ) || ! $product->is_visible() ) {
  27.     return;
  28. }
  29. ?>
  30. <li <?php post_class(); ?>>
  31.     <?php
  32.     echo '<figure class="image_block">';
  33.     /**
  34.      * woocommerce_before_shop_loop_item_title hook.
  35.      *
  36.      * @hooked woocommerce_show_product_loop_sale_flash - 10
  37.      * @hooked woocommerce_template_loop_product_thumbnail - 10
  38.      */
  39.     do_action( 'woocommerce_before_shop_loop_item_title' );
  40.  
  41.  
  42.     echo '</figure><div class="product_info">';
  43.     echo '<ul class="rating">';
  44.     $rating_average = round($product->get_average_rating());
  45.     for ($i = 0; $i < $rating_average; $i++) {
  46.         echo '<li class="star"></li>';
  47.     }
  48.     for($i = 0; $i < (5-$rating_average); $i++) {
  49.         echo '<li class="no_star"></li>';
  50.     }
  51.     echo '</ul>';
  52.     /**
  53.      * woocommerce_before_shop_loop_item hook.
  54.      *
  55.      * @hooked woocommerce_template_loop_product_link_open - 10
  56.      */
  57.     do_action( 'woocommerce_before_shop_loop_item' );
  58.    
  59.     /**
  60.      * woocommerce_shop_loop_item_title hook.
  61.      *
  62.      * @hooked woocommerce_template_loop_product_title - 10
  63.      */
  64.     do_action( 'woocommerce_shop_loop_item_title' );
  65.     echo wc_get_product_category_list( $product->get_id(), ', ', '<p class="description">' . _n( '', '', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '</p>' );
  66.  
  67.     /**
  68.      * woocommerce_after_shop_loop_item_title hook.
  69.      *
  70.      * @hooked woocommerce_template_loop_rating - 5
  71.      * @hooked woocommerce_template_loop_price - 10
  72.      */
  73.     remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5);
  74.     do_action( 'woocommerce_after_shop_loop_item_title' );
  75.  
  76.  
  77.     /**
  78.      * woocommerce_after_shop_loop_item hook.
  79.      *
  80.      * @hooked woocommerce_template_loop_product_link_close - 5
  81.      * @hooked woocommerce_template_loop_add_to_cart - 10
  82.      */
  83.     do_action( 'woocommerce_after_shop_loop_item' );
  84.     echo '</div>';
  85.     ?>
  86. </li>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement