G
G
Genri_Rus2019-12-14 22:48:19
WordPress
Genri_Rus, 2019-12-14 22:48:19

How to show discounts and rating when displaying one category?

Here is an example:
5df53b49bee24129626920.png5df53b52cc2a2563153815.png
How to customize reviews and discounts?
I create a loop like this:

<?php
      $args = array(
        'posts_per_page' => 12,
        'post_type' => 'product',
        'order' => 'ASC',
        'tax_query' => array(
          array(
            'taxonomy' => 'product_cat',
            'field' => 'slug',
            'terms' => 'books'
          ),
        ),  
      );

      $category_books = new WP_Query( $args );
      while ( $category_books->have_posts() ) : $category_books->the_post();
      global $product;
    ?>

I get prices like this, right?
$regular_price = method_exists( $product, 'get_regular_price' ) ? $product->get_regular_price() : $product->regular_price;
$sale_price = method_exists( $product, 'get_sale_price' ) ? $product->get_sale_price() : $product->sale_price;

Because if I edit in the loop/sale-flash.php folder, then nothing changes

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question