Hello,
I’m currently experiencing a critical issue with the WooCommerce integration on the Woodmart theme. Below are the details of the problem:
I’m using the Woodmart theme along with the Paynet payment gateway plugin for WooCommerce. The payment process completes successfully; however, after the transaction, when the user is redirected to the default WooCommerce “thank you” page, a fatal error occurs in the single-product/product-image.php template file:
PHP Fatal error: Uncaught Error: Call to a member function get_gallery_image_ids() on null
in /themes/woodmart/woocommerce/single-product/product-image.php:27
This happens because the $product object is null at that moment. It seems that the Paynet plugin does not pass a valid $product instance upon redirect, and the theme template is attempting to use it without validation.
To prevent this, I tried adding the following conditional check at the beginning of the product-image.php file:
global $product;
if ( ! $product ) {
$product = wc_get_product( get_the_ID() );
}
if ( ! is_a( $product, ‘WC_Product’ ) ) {
return;
}
Unfortunately, the issue persists. It is likely that other WooCommerce template files within the theme are also accessing the $product object without proper validation, causing the site to crash on the “thank you” page with a critical error message.
What I kindly request:
Please consider implementing safer checks before using the $product object within WooCommerce templates.
Ideally, ensure that components dependent on product data do not load or execute on pages like the order confirmation (thank you) page where $product may not be available.
I would greatly appreciate your help in resolving this issue. I can provide error logs and screenshots if necessary.
Thank you in advance,
Ahmet