在Woo-commerce中,可以设置默认商店页面以按类别显示产品。这样做时,它会列出缩略图/标题/链接/可用的产品数量。
但它没有显示价格。
目标是列出产品类别并列出其产品的起始价格。例如:1类起价为9.99美元(1类最便宜的产品为9.99)
提示/技巧/想法都将受到赞赏
以下是用于该页面的默认模板:
<?php
/**
* The template for displaying product category thumbnails within loops.
* Override this template by copying it to yourtheme/woocommerce/content-product_cat.php
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $woocommerce_loop;
// Store loop count we're currently on
if ( empty( $woocommerce_loop['loop'] ) )
$woocommerce_loop['loop'] = 0;
// Store column count for displaying the grid
if ( empty( $woocommerce_loop['columns'] ) )
$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 4 );
// Increase loop count
$woocommerce_loop['loop']++;
?>
<li class="product-category product<?php
if ( ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] == 0 || $woocommerce_loop['columns'] == 1 )
echo ' first';
if ( $woocommerce_loop['loop'] % $woocommerce_loop['columns'] == 0 )
echo ' last';
?>">
<?php do_action( 'woocommerce_before_subcategory', $category ); ?>
<a href="<?php echo get_term_link( $category->slug, 'product_cat' ); ?>">
<?php
/**
* woocommerce_before_subcategory_title hook
*
* @hooked woocommerce_subcategory_thumbnail - 10
*/
do_action( 'woocommerce_before_subcategory_title', $category );
?>
<h3>
<?php
echo $category->name;
if ( $category->count > 0 )
echo apply_filters( 'woocommerce_subcategory_count_html', ' <mark class="count">(' . $category->count . ')</mark>', $category );
?>
</h3>
<?php
/**
* woocommerce_after_subcategory_title hook
*/
do_action( 'woocommerce_after_subcategory_title', $category );
?>
</a>
<?php do_action( 'woocommerce_after_subcategory', $category ); ?>
</li>
答案 0 :(得分:0)
我终于能够完成这项工作,并在其上写了一篇快速文章:
http://wastelandgraphics.com/woocommerce-get-lowest-price-category-archive-archive-product-php/