1 回答

TA贡献1829条经验 获得超9个赞
只需使用以下WC_Product方法get_price_html()即可:
<div class="searchproduct">
<div class="searchsingle">
<?php the_post_thumbnail( 'medium_large' ); ?>
<h2 class="woocommerce-loop-product__title"><?php echo esc_html( get_the_title() ); ?></h2>
<div class="price"><?php echo $product->get_price_html(); ?></div>
<a href="<?php the_permalink(); ?>">
<div class="button"><?php _e("Ajouter au panier", 'woocommerce'); ?</div>
</a>
</div>
</div>
或者,如果您在产品促销时只想要一种格式的价格,您将使用:
<div class="searchproduct">
<div class="searchsingle">
<?php the_post_thumbnail( 'medium_large' ); ?>
<h2 class="woocommerce-loop-product__title"><?php echo esc_html( get_the_title() ); ?></h2>
<div class="price"><?php wc_price( wc_get_price_to_display($product) ); ?></div>
<a href="<?php the_permalink(); ?>">
<div class="button"><?php _e("Ajouter au panier", 'woocommerce'); ?</div>
</a>
</div>
</div>
- 1 回答
- 0 关注
- 78 浏览
添加回答
举报