When trying to edit a Page in one of our WordPress sites, some pages load normally and are editable however some pages are showing an error in one of the theme modules. This is what we see:
Fatal error: Uncaught exception 'Exception' with message 'Invalid product.' in /home/prikkabelled/public_html/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php:133 Stack trace: #0 /home/prikkabelled/public_html/wp-content/plugins/woocommerce/includes/class-wc-data-store.php(143): WC_Product_Data_Store_CPT->read(Object(WC_Product_Bundle)) #1 /home/prikkabelled/public_html/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-product.php(126): WC_Data_Store->read(Object(WC_Product_Bundle)) #2 /home/prikkabelled/public_html/wp-content/plugins/woocommerce-product-bundles/includes/class-wc-product-bundle.php(117): WC_Product->__construct('7854') #3 /home/prikkabelled/public_html/wp-content/plugins/woocommerce-product-bundles/includes/admin/meta-boxes/class-wc-pb-meta-box-product-data.php(136): WC_Product_Bundle->__construct('7854') #4 [internal function]: WC_PB_Meta_Box_Product_Data::product_data_tabs(Array) #5 /home/prikkabelled/public_html/wp-includes/class-wp-hook.php(298): call in /home/prikkabelled/public_html/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php on line 133
We've updated the theme to the latest version (Electro). We have also updated Visual Composer plugin, WordPress and WooCommerce to latest version.
Strange thing is that just some pages are showing this error in page edit mode while on the frontend, the pages look normal. This error is preventing us from editing the page in any way.
Any idea what could be the cause?
The error means what it says:
Fatal error: Uncaught exception 'Exception' with message 'Invalid product.' in /home/prikkabelled/public_html/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php:133
Stack trace:
#0 /home/prikkabelled/public_html/wp-content/plugins/woocommerce/includes/class-wc-data-store.php(143): WC_Product_Data_Store_CPT->read(Object(WC_Product_Bundle))
#1 /home/prikkabelled/public_html/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-product.php(126): WC_Data_Store->read(Object(WC_Product_Bundle))
#2 /home/prikkabelled/public_html/wp-content/plugins/woocommerce-product-bundles/includes/class-wc-product-bundle.php(117): WC_Product->__construct('7854')
#3 /home/prikkabelled/public_html/wp-content/plugins/woocommerce-product-bundles/includes/admin/meta-boxes/class-wc-pb-meta-box-product-data.php(136): WC_Product_Bundle->__construct('7854')
#4 [internal function]: WC_PB_Meta_Box_Product_Data::product_data_tabs(Array)
#5 /home/prikkabelled/public_html/wp-includes/class-wp-hook.php(298): call in /home/prikkabelled/public_html/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php on line 133
(I've corrected the formatting for readability.)
Follow that stack trace, and you will find code that throws an exception with the message, "Invalid product." But the exception isn't caught in a catch or with set_exception_handler(), so it brings the program to a halt.
Exactly why it happens is impossible to say because you haven't posted a Minimal, Complete, and Verifiable example. But following the stack trace should make it obvious.
The error went away when we deactivated a plugin called WooCommerce Product Bundles. Error #2 in the stack trace was a clear giveaway.
#2 /home/prikkabelled/public_html/staging1/wp-content/plugins/woocommerce-product-bundles/includes/class-wc-product-bundle.php(117): WC_Product->__construct('5301')
However, we still require this plugin so I'm going to report the issue to WooCommerce dev team since the error begins in their plugin.