TIV WooCommerce Multi-currency: Developers FAQ

Multi-currency for WooCommerce by TIV.NET

https://woocommerce.com/products/multi-currency/

How do I get the currently selected currency?

↑ Back to top
get_woocommerce_currency()

How to set the currency when I create an order programmatically?

↑ Back to top

You need to override the active currency temporarily:

function ___return_currency_USD() {
	return 'USD';
}

// Temporarily set active currency to "USD".
\add_filter( 'woocommerce_multicurrency_override_currency', '___return_currency_USD' );

// Create order programmatically.
$logger     = \wc_get_logger();
$product_id = 10;
try {
	$order = \wc_create_order();
	$order->add_product( \wc_get_product( $product_id ), 1 );
	$order->calculate_totals();
	$order->save();
	$logger->log( \WC_Log_Levels::INFO, 'Order total = ' . $order->get_total() . ' ' . $order->get_currency() );
} catch ( \Exception $exception ) {
	$logger->log( \WC_Log_Levels::ERROR, "Cannot add product ID {$product_id} to the order." );
}

// Stop overriding currency.
\remove_filter( 'woocommerce_multicurrency_override_currency', '___return_currency_USD' );

TIV.NET INC., based in Toronto, Canada, develops and supports the following WooCommerce extensions:

↑ Back to top
TIV Admin ToolsA set of utilities for WooCommerce shop owners, administrators, and developers to secure, tune, and debug their store.
TIV GlobusMakes WooCommerce multilingual – translate product descriptions, categories, attributes, and tags.
TIV Multi-currencyLets customers pay in the currency of their choice.
TIV PaywallEnables the monetization of various types of content, including videos, documents, etc., by allowing the sale of access to it.
TIV Sales AssistantManage store-wide sales from one place – schedule discounts by category, tag, and country instead of editing products one by one.

Related Products

WooCommerce Subscriptions is a WooCommerce extension that lets customers subscribe to your products or...

Power your membership association, online magazine, elearning sites, and more with access control to...

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.