Answer the question
In order to leave comments, you need to log in
How to show discounts and rating when displaying one category?
Here is an example:
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;
?>
$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;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question