NO BUG: Custom code breaking the front page only

Bricks Version: 1.5.7
Browser: Chrome 90
OS: windows

Hi,
I created a custom code to display the percentage of a sale product

It works on the single product page, but on the home page everything is messed up.

Kind regards

Hi @intovortex ,

Maybe you should set this in wp-config.php

define( 'WP_DEBUG', true );

Then check the error log.

I suspect you might need to add some checking before accessing $product variable.
Example:

if( is_a($product, 'WC_Product') )

And also maybe need to get the regular price or sale price by using

$product->get_regular_price();
$product->get_sale_price();

Regards,
Jenn

Hey @itchycode thanks for getting back to me.

Thank you for the help, that almost solved the problem, I also had to include is_product() to make it work

Kind regards

1 Like

Glad that helps! Thanks for sharing your amended code too!

1 Like

Thank you again, and you welcome :innocent: