WCML Bug Report: ResolverForModeLocation Issue
-
When attempting to create orders in the WordPress admin panel, an error occurs due to an interaction between WooCommerce and WooCommerce Multilingual & Multicurrency (WCML). The error message is: Copy
Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /usr/www/users/cardks/staging/wp-content/plugins/woocommerce/includes/wc-core-functions.php:1331
This error occurs in the
wc_get_customer_default_location()
function. The site is multilingual, uses multiple currencies, and sells products worldwide. Deactivating WCML allows orders to be created successfully, but the error returns when WCML is reactivated. Environment- WordPress version: 6.6
- WooCommerce version: 9.0.0+
- WCML version: 5.3.6
- PHP version: 8.2.21
Steps to Reproduce
- Ensure WCML is activated.
- Go to the WordPress admin panel.
- Attempt to create a new order.
- Observe the error message.
Expected Behavior
The order should be created successfully without any errors, maintaining multilingual and multi-currency functionality.
Actual Behavior
An error is thrown, preventing the creation of the order. Debugging Information
The error occurs in the
ResolverForModeLocation
class, specifically in thegetClientCurrency()
method. It appears that this method is being called before WooCommerce is fully initialized, or when some expected WooCommerce data is not available. Proposed SolutionAfter investigation, we found that adding some checks and error handling in the
ResolverForModeLocation
class resolves the issue. I’m not sure if adding the code here is allowed.This modification adds checks to ensure WooCommerce is initialized, handles potential exceptions, and provides a fallback mechanism when the expected data is not available. Impact
This issue prevents users from creating orders in the admin panel when WCML is active, which is a critical functionality for e-commerce sites. Resolving this would significantly improve the stability and usability of WCML for users who sell products worldwide and utilize multiple currencies. Additional Notes
- The site sells products worldwide, so solutions that restrict countries are not viable.
- The issue appears to be related to the interaction between WooCommerce and WCML, specifically in how WCML handles currency and location data.
- Temporary workaround: Deactivating WCML allows orders to be created, but this is not a long-term solution as it disables essential multilingual and multi-currency functionality.
We appreciate your attention to this matter and look forward to a resolution that maintains the full functionality of WCML while allowing seamless order creation.
- You must be logged in to reply to this topic.