1 回答

TA貢獻(xiàn)1829條經(jīng)驗 獲得超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>
或者,如果您在產(chǎn)品促銷時只想要一種格式的價格,您將使用:
<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 關(guān)注
- 100 瀏覽
添加回答
舉報