This code is written to change the currency of manual (admin-created) orders to a custom currency when the orders are created, specifically when the order status is ‘on-hold’. The hook ensures that this process occurs when a new order is created in the WooCommerce store.
add_action('woocommerce_new_order', 'set_custom_currency_for_manual_orders', 10, 1);
function set_custom_currency_for_manual_orders($order_id) {
// Check if the order is manual (admin-created) by looking at the order status
$order = wc_get_order($order_id);
$order_status = $order->get_status();
// Specify the custom currency code you want to set for manual orders
$custom_currency_code = 'EUR';
// Check if the order is manual (e.g., status is 'on-hold' for admin-created orders)
if ($order_status === 'on-hold') {
// Set the custom currency for the order
$order->set_currency($custom_currency_code);
$order->save();
}
}
After adding the code to your child themes functions file, click Add Order, change the status to On Hold and click Create.

How The Code Works
- function set_custom_currency_for_manual_orders($order_id) { … }
- This function is designed to be hooked into the
woocommerce_new_orderaction. It triggers when a new order is created. - It takes the order ID as a parameter.
- This function is designed to be hooked into the
- $order = wc_get_order($order_id);
- This line uses the
wc_get_orderfunction to retrieve the WooCommerce order object based on the provided order ID.
- This line uses the
- $order_status = $order->get_status();
- It retrieves the status of the order using the
get_statusmethod on the order object. The order status represents the current state of the order.
- It retrieves the status of the order using the
- $custom_currency_code = ‘YOUR_CUSTOM_CURRENCY_CODE’;
- A custom currency code is specified here. You should replace
'YOUR_CUSTOM_CURRENCY_CODE'with the actual currency code you want to set for manual orders.
- A custom currency code is specified here. You should replace
- if ($order_status === ‘on-hold’) { … }
- This condition checks if the order status is ‘on-hold’. This is often used to identify admin-created or manual orders.
- $order->set_currency($custom_currency_code);
- If the order is indeed a manual order (on-hold status), this line sets the order’s currency to the custom currency code specified earlier.
- $order->save();
- This saves the changes made to the order, including the updated currency.
- add_action(‘woocommerce_new_order’, ‘set_custom_currency_for_manual_orders’, 10, 1);
- This line hooks the
set_custom_currency_for_manual_ordersfunction into thewoocommerce_new_orderaction with a priority of 10 and expects one parameter (order ID).
- This line hooks the
Related Solutions
Was this helpful?
Thanks for your feedback!

Leave a Reply