I have the following code to display price once entering single product page.
<?php
global $woocommerce;
$product = new WC_Product(get_the_ID());
echo $product->get_price_html(); //Shows the price
?>
I have tried serval variation of this code, but they all either error or empty value.
Although <?php echo get_the_title() ?>
does work.
What can be causing get_price_html()
to echo empty value?