Woocommerce price not displaying for simple product

Hi Movin,

I tried to add a “simple product” to my site today using Woocommerce and the price isn’t displaying on the single product page, link is here: https://theraininspain.net/shop/harmony/cleopatra-royal-blue/

All the other products on my website are “variable products” and the pricing for them show up once the variable selections have been made on the single product pages. I’m therefore not sure why the price won’t display for this new product page, I’m guessing maybe it has something to do with it being a ‘simple’ product rather than ‘variable’ but I’m not sure.

Any help you could provide would be great and very appreciated.

Many thanks
Mapes

Hi Mapes,

I hope you are well today and thank you for your question.

I have tested it on my test site and it’s working fine for me using latest version of Activello theme as displayed in the attached screenshots.

This can be child theme issue on your site so to confirm it just temporary use the Activello theme instead of child theme on your site. If everything works fine then it’s your child theme issue so just share me your child theme so that i can troubleshoot it.

Best Regards,
Movin

Hi Movin

Thanks for your quick reply. You’re right - when I do a live preview with the Activello theme itself, the price displays without any issue.

I remember I did change some of the php code of the child theme single product page a while ago to move around some of the display, most likely I did something wrong! I’ve attached the relevant file, but if there’s a better way to share the theme with you please let me know, I’m not quite sure how.

Many thanks
Mapes

Oh it looks like I can’t attach the php file. I’ve copied and pasted the code into the attached word doc instead.

Sorry Movin I can’t seem to share the file with you even in gdoc…if you could please let me know the best way I’ll do my best to share thanks.

Hi Movin

I know what the problem is I think but I don’t know how to fix it. I had added in the below code previously to get rid of the pricing line, as it shows a pricing range when I have variable products and it was confusing for customers.

<?php
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10);
?>

Is it possible to write the add_action code so that it only displays the price when there is no drop-down selection to make (i.e. not a variable product)?

Thanks
Mapes

Hi Movin

I figured out the code today to hide the variable price range on a single product page:

add_filter( ‘woocommerce_variable_sale_price_html’, ‘hide_variable_prices’, PHP_INT_MAX, 2 );
add_filter( ‘woocommerce_variable_price_html’, ‘hide_variable_prices’, PHP_INT_MAX, 2 );
function hide_variable_prices($html) {
if ( is_product() ) {
return ‘<p class=“variable_price”>Select an option to show its price.</p>’;
} else {
return $html;
}
}

Taken from topic discussion here: Woocommerce – Replacing Price Range When Variation Selected | WordPress.org

Thanks very much for your help in pointing me in the right direction for this!! Really appreciate it.

Cheers
Mapes

You are most welcome here :slight_smile: