Skip to content

Instantly share code, notes, and snippets.

@braddalton
Created December 13, 2023 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braddalton/02d6a3f5b7c2a9552d6025259afb595f to your computer and use it in GitHub Desktop.
Save braddalton/02d6a3f5b7c2a9552d6025259afb595f to your computer and use it in GitHub Desktop.
Change Currency for Manual Orders in WooCommerce https://wpsites.net/?p=114652
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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment