Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda