I've created a plugin on Wordpress with Gutenberg, which deletes a lot of blocks on the "single-product" page. I wanted to create a nice page for each products.
To do this, in my plugin, I created a function which removes all the layout of WooCommerce.
After that, I created a function which creates a "block" in Gutenberg which displays the price whereIi want, as well as the "add to cart".
To display the price, here is my code :
function lsc_product_price() {
ob_start();
woocommerce_template_single_price();
$content = ob_get_contents();
ob_end_clean();
return $content;
}
The code is almost the same for the "add to cart".
When I use my "price" block with Gutenberg, some times, my cart is down and I can't even access to the cart page.
There is the error of Wordpress :
Fatal error: Uncaught Error: Call to a member function get_price_html() on null in /home/.../public_html/wp-content/plugins/woocommerce/templates/single-product/price.php:25
At this line, we have :
<p class="<?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price' ) ); ?>"><?php echo $product->get_price_html(); ?></p>
I know that there may be a conflict between plugins, and I know that my plugin conflicts suddenly.
I understand the error, but I don't know how to resolve it. I tried to search some info on Google or StackOverFlow, but I couldn’t find anything that would help me.