Created
December 13, 2023 13:13
-
-
Save braddalton/02d6a3f5b7c2a9552d6025259afb595f to your computer and use it in GitHub Desktop.
Change Currency for Manual Orders in WooCommerce https://wpsites.net/?p=114652
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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