• Resolved Antony Booker

    (@antonynz)


    I’m getting a fatal error when the price html filter is called within WC blocks on a non product page.

    This occurs due to the get_the_ID() function in vpd_get_price_html getting the ID of the page instead of the product, then performing the is_type( ‘variable’ )) check which will return an error when the get_the_ID doesn’t return a product ID.

    I also noticed the arguments passed to the woocommerce_variable_price_html filter don’t match the accepted arguments, and the product object can actually be called directly.

    To fix this are you able to release a patch and replace the following code:

    function vpd_get_price_html( $filter, $price = '' ){
    
    		$product = wc_get_product( get_the_ID() );
    		
    		if($product->is_type( 'variable' )):

    With:

    function vpd_get_price_html( $price , $product ){
    
    		if($product->is_type( 'variable' )):

    Hope that helps. Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Hakik Zaman

    (@hakik)

    Hi @antonynz

    Thanks for reporting this issue. As far I know, WC Block (All Product Gutenberg Block) uses a different mechanism to get the price.

    But again a great thanks for reporting this. I will definitely apply your suggested code and will try to update it ASAP.

    Did you try to change the code? Is it working with the WC Gutenberg Block?

    Thanks

    Plugin Author Hakik Zaman

    (@hakik)

    Hi again,

    Just release v1.1.1 and changed the parameter as you suggested.

    Thanks again for reporting the issue.

    Have a great day!

    Thread Starter Antony Booker

    (@antonynz)

    Thanks for making that change so quickly. The WC blocks must load the products outside of a loop, this will fix that issue though.

    Much appreciated.

    Plugin Author Hakik Zaman

    (@hakik)

    Thanks for your appreciation.

    If you like this plugin. My humble request to you is to write your beautiful thought here.

    It will inspire me a lot.

    Thanks again.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Fatal error in price filter’ is closed to new replies.