Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
Call to a member function get_price_html() on null - Wordpress/WooCommerce/PHP

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!