Ecommerce Shopify WordPress Discussion

How can I fetch the order currency in WooCommerce with HPOS compatibility?

I'm working on a WooCommerce project and facing an issue with fetching the correct currency for orders when High Performance Order Storage (HPOS) is enabled. My goal is to retrieve the currency specifically from the WooCommerce edit order page. Currently, my code returns the default currency set in WooCommerce settings, not the actual currency of the individual order. Here's the code snippet I'm using: private static function getAdminOrderCurrency($order): string { if (OrderUtil::custom_orders_table_usage_is_enabled()) { // HPOS usage is enabled. $order_id = get_the_ID(); $order = wc_get_order($order_id); return $order->get_currency(); } else { // Traditional CPT-based orders are in use. global $post; $order_id = $post->ID; $order = wc_get_order($order_id); return $order->get_currency(); } } Despite this implementation, the function returns the default WooCommerce currency instead of the actual currency of the order. Could anyone suggest what might be going wrong or how to ensure compatibility with HPOS to fetch the correct currency from the WooCommerce order? Any insights or suggestions would be greatly appreciated!
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.