Get rid of related product and cross sells error on product single page

Hello please i keep having these error on my single product pages

Undefined variable: related_products in /data/wwwroot/beta.mysite.com/wp-content/themes/pro/woocommerce/single-product/related.php on line 13

Notice: Undefined variable: upsells in /data/wwwroot/beta.mysite.com/wp-content/themes/pro/woocommerce/single-product/up-sells.php on line 13

how to get rid of them?

after reading a lot on the forum, i added these to my child theme functions.php but it is no use.
remove_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_output_related_products’, 20 );
remove_action( ‘woocommerce_cart_collaterals’, ‘woocommerce_cross_sell_display’);

i also disabled cross sell and related product in pro customiser

Hi There @khiloc

Thanks for writing in! Basically you can ignore PHP notices by disabling WordPress debug mode. Please refer to the following WordPress documentation handle on how to disable debugging mode (https://codex.wordpress.org/WP_DEBUG).

Also to avoid such incompatibility issues, make sure to update your PHP version to v5.6.x or later. You can contact your hosting provider to do that or some hosting providers allows to switch PHP versions through their control panel.

Hope that helps.

hello
my define(‘WP_DEBUG’, false);
is already at false but this is still displaying

Hi There @khiloc

Could you please try updating your code as follows.

define( 'WP_DEBUG', true ); 
if ( WP_DEBUG ) {
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );
    @ini_set( 'display_errors', 0 );
}

This will create an error log file under your wp-content directory, with the name of debug.log which will record any errors.

Thanks!

hi
thanks for input
while waiting for your reply i tried just by renaming the unused files causin error from my child theme…
but it was not working…
so i renamed them directory from theme
/wp-content/themes/pro/woocommerce/single-product/related.php to related.php.old
/wp-content/themes/pro/woocommerce/single-product/up-sells.php to up-sells.php.old

and error is gone

why renaming from child theme did not work…
because now as i deleted from theme itself, on next update i will loose those changes again

Hey @khiloc,

Renaming the files in your child theme essentially makes unreadable so the files from the parent theme will be used.

When this happens again, try enabling the Related Products and Upsells options and check if the values are blank like this:

If you see that, try setting them up then disable the options again.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.