Open adkoen opened 8 months ago
I think I just stumbled upon the same issue.
Using a "product is on sale" condition in a single product template causes the following error:
Call to a member function is_on_sale() on string in /home/.../wp-content/plugins/breakdance/plugin/themeless/rules/woocommerce/product-sale.php:38
The source code of the function where the error is thrown:
function ($operand, $value): bool {
global $product;
if (!$product) {
return false;
}
/** @var \WC_Product $product */
$product = $product;
if ($value === 'on_sale') {
return $product->is_on_sale();
}
if ($value === 'not_on_sale') {
return !$product->is_on_sale();
}
return false;
}
Looks like global $product;
produces a string.
So the problem is that using the global $product in a shortcode in a woocommerce single template returns a string instead of the product object. It looks like the loop of Breakdance somehow causes this.