How to use WooCommerce’s default price at any custom template

wordpressTo use WooCommerce’s price in your custom theme template open the template file and use the following code and see the magic.

global $post, $product;
<span itemprop=”price” class=”price”><?php echo $product->get_price_html(); ?></span>

For default price template file of woocommerece you can look at folloiwng location
yourtheme/woocommerce/loop/price.php. Open the file up and see the code used for the same
global $product;

<?php if ( $price_html = $product->get_price_html() ) : ?>
<span class=”price”><?php echo $price_html; ?></span>
<?php endif; ?>

Like to share it

Leave a comment

Your email address will not be published. Required fields are marked *