New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRITICAL Uncaught Error: Call to a member function get_type() on bool #336
Comments
Even if the product is external the product data should still return like any other. Go to "WooCommerce > System Status. There will be a button to press to copy the system status report. Just paste it here please. Thanks. |
It could also be an issue with WC it's self in supporting PHP 8. Your method to wrap in an if condition should be fine. Will push a patch asap. |
sorry for not being more specific on this one. i run a filter on system report: WordPress EnvironmentWC Version: 6.4.1 Server EnvironmentServer Info: Apache SUHOSIN Installed: – DatabaseWC Database Version: 6.4.1 Post Type Countsacf-field: 39 SecuritySecure connection (HTTPS): ✔ Active Plugins (23)Advanced Custom Fields PRO: by Delicious Brains – 5.12.2 Invoices for WooCommerce: by Bas Elbers – 3.1.9 Inactive Plugins (4)Maintenance: by WebFactory Ltd – 4.05 Must Use Plugins (4)Bedrock Autoloader: by Roots – 1.0.3 SettingsAPI Enabled: ✔ Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) Connected to WooCommerce.com: ✔ WC PagesShop base: #11 - /shop/ ThemeName: Vue.wordpress TemplatesOverrides: – Action SchedulerComplete: 1,266 CoCartVersion: 3.6.0 Carts in Session: 165 Status report informationGenerated at: 2022-05-06 09:24:07 +02:00 |
Describe the bug
i got this fatal 500:
from loading a bunch of products e.g.
/wp-json/cocart/v2/products/?per_page=20&page=2
The issue is as follows:
The function
get_connected_products()
receives some product ids, guess for related / cross sells etc.. products.in line 683
you call for$_product = wc_get_product( $id );
but in my case it returns false. not really sure, why that is. i checked one product that was causing this issue, but it had no related/cross sells set, means these get set by wc. but sincewc_get_product()
only returns bool false, following line$_product->get_type()
crashes, resulting in fatal error 500Prerequisites
trunk
branch of CoCart on GitHub.dev
branch of CoCart on GitHub (this is not the same version as on WordPress.org!).Steps to reproduce the issue
i have no clue, why this is happening. maybe it is caused by some external products? these do exist in the mentioned shop but are excluded from the default shop overview. they have their own section in the shop.
Expected/actual behavior
When I follow those steps, I see...
I was expecting to see...
Screenshots
Isolating the problem
WordPress Environment
wp and plugins are all latest. php 8.0.16
Additional context
i got rid of the error, by wrapping the following lines into
if
statement:but i am not sure, why
wc_get_product()
returns false in the first place..The text was updated successfully, but these errors were encountered: