Fatal error in price filter
-
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.
The topic ‘Fatal error in price filter’ is closed to new replies.