• 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

    1. Ensure WCML is activated.
    2. Go to the WordPress admin panel.
    3. Attempt to create a new order.
    4. 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 the getClientCurrency() method. It appears that this method is being called before WooCommerce is fully initialized, or when some expected WooCommerce data is not available. Proposed Solution

    After 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.

    • This topic was modified 4 months, 1 week ago by Abde.
Viewing 1 replies (of 1 total)
  • Plugin Support Andrés Cifuentes

    (@andrescifuentesr)

    Hello @ultrell,

    Thank you for your detailed and comprehensive report. However, I’ve tried to reproduce it on the following sandbox and I can’t replicate it. As you can imagine, it is critical for us to be able to reproduce the issue. In that way we will be able to investigate it and provide the best resolution for it. Could you please give it a try? I may be missing a step.

    On the other hand, as it is a multilingual site and it will be most probably associated, in case that you are using WPML, please go to our support forum and open a chat there, we have all the required tools to assist you and we will be happy to help you to solve this issue quickly.

    Regards,
    Andrés

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.