Background of the issue:
Inside Admin Panel, WooCommerce Analytics > Coupons > I am trying to check the data for any coupon with currency USD then it is showing me result which is fine but when I select any other currency like Euro, Singapore dollar then it is showing error [ hidden link ]. I have even checked inside network, it is showing status 500 - [ hidden link ], showing first error request [ hidden link ]. But in case of selecting currency as US dollar then it is working fine and showing the result - see screenshot of Network Tab [ hidden link ], [ hidden link ].
Symptoms:
When selecting any currency other than USD in WooCommerce Analytics > Coupons, it shows a status 500 error.
Questions:
Why does selecting currencies other than USD in WooCommerce Analytics > Coupons result in a status 500 error?
How can I resolve the issue of WooCommerce Analytics not working with multiple currencies?
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+02:00)
Can you try this?
add_filter('wcml_client_currency', array($this, 'modify_client_currency'), 10, 1);
public function modify_client_currency($current_currency) {
// Ensure the WooCommerce session is initialized
if (class_exists('WooCommerce') && method_exists(WC(), 'initialize_session')) {
WC()->initialize_session();
}
// Check if the session is set and return the session currency if available
if (isset(WC()->session) && WC()->session->get('wcml_curr')) {
return WC()->session->get('wcml_curr');
}
// Check for a currency parameter in the URL and update the session accordingly
if (isset($_GET['currency']) && $_GET['currency']) {
if (!is_admin() && class_exists('WCML_Currency_Switcher')) {
$currencies = Settings::getOrderedCurrencyCodes();
$currency = strtoupper(esc_attr($_GET['currency']));
if (in_array($currency, $currencies)) {
if (isset(WC()->session)) {
WC()->session->set('wcml_curr', $currency);
} else {
// Log an error or handle the case where the session is not available
error_log('WC()->session is not available');
}
return $currency;
}
}
}
return $current_currency;
}
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.