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; ?>

Shashi Dhar Kumar Experience in Web/software development including client server and implementation using PHP, XML, MySQL and SQL Server. Experience of working on Apache, Linux projects, Javascript, Ajax, Putty, FTP, Remote Connection, XML parsing, Mod-Rewriting, Payment Gateways and shipping modules, Trouble shooting and Manual Testing.

No comments

Leave a Reply

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