[Waiting for user feedback] Fatal Error with get_stock_quanity()
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Our wait time is higher than usual, please make sure you are meeting the minimum requirement - https://wpml.org/home/minimum-requirements before you report issues, and if you can take a look at current Known Issues - https://wpml.org/known-issues/. Thank you.
Background of the issue:
I am trying to save products in WooCommerce, but I encounter a fatal error. This issue does not occur with all products. I have already fixed one product by deleting and recreating it. Here is a link to a screenshot of the error: hidden link. The following plugins are up to date: WooCommerce - 9.1.2, WooCommerce Multilingual & Multicurrency - 5.4.4, WPML Multilingual CMS - 4.7.3.
Symptoms:
Fatal error with get_stock_quanity() when saving products.
Questions:
Why am I getting a fatal error when saving some products?
How can I prevent this error from occurring again?
Thanks for sharing the error details. We’ve reviewed the issue with our second-tier team, and based on the error message, it appears that the system is attempting to retrieve stock information from a product variation that doesn't exist or is not properly recognized — resulting in a fatal error when calling get_stock_quantity() on a boolean (false).
Here’s what could be happening and how to investigate further:
What Might Be Causing the Issue:
A variation may be listed under the product that no longer exists or is incomplete.
A variation may be assigned, but its translation is missing, or the postmeta data is corrupted.
There could also be a database inconsistency, particularly in WooCommerce’s variation handling or post relationships.
Suggested Steps to Investigate:
Check the variations of the product that trigger the error:
Look in the database (wp_posts) for entries where post_parent matches the product’s ID and post_type = 'product_variation'.
Then, check if all of these variations are appropriately translated (in wp_icl_translations).
If you're comfortable editing the code, you can add a temporary debug line before the error line in:
**** Important! Please make a full site backup (files and DB) before you proceed with those steps****
This will log the product object to your error log, which can help us confirm whether it's a valid variation object.
If you'd prefer, you can also send us a package of the site, and we can investigate the issue further. You can upload it to a service like Google Drive or Dropbox and share the link with me. Or you can give us access and allow me to take a copy of your site. I must install a plugin like Duplicator or All In One Migration for this. Please let me know if you agree. For this, I'll enable private messages for the following reply.
Let us know how you'd like to proceed or if you’d like assistance checking the variation entries.
In WPML -> Settings -> Posts and pages synchronization, you need to select 'When deleting a post, delete translations as well', and then when you delete the English variable product, its translation, including the variations, will be deleted. Please note that sending a product to the trash section is not a complete deletion of it. You must permanently delete it from the trash section.
Please let me know if you have any further questions.