How to get the order value in default currency once the order is placed in any other currency
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page pleaseIf you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
Quote from Chic on January 24, 2023, 11:45I want to get the line_total and order_total in default currency once the order is placed in any other currency.
When i use this function $order->get_line_total(), it gives me the converted price not in default currency.
Which function i can use in function.php to get these values in default currency?
I want to get the line_total and order_total in default currency once the order is placed in any other currency.
When i use this function $order->get_line_total(), it gives me the converted price not in default currency.
 Which function i can use in function.php to get these values in default currency?
Quote from Pablo Borysenco on January 24, 2023, 12:47Hello
Yes, the order is stored in the currency of which the payment was made
you should get the currency and rate of the order :
$_order_currency = get_post_meta($order_id, '_order_currency', true);
$order_rate = get_post_meta($order_id, '_woocs_order_rate', true);and back convert the amount(if order currency is not base):
$total = $total/$order_rate
Hello
Yes, the order is stored in the currency of which the payment was made
you should get the currency and rate of the order :
$_order_currency = get_post_meta($order_id, '_order_currency', true);
 $order_rate = get_post_meta($order_id, '_woocs_order_rate', true);
and back convert the amount(if order currency is not base):
$total = $total/$order_rate
Quote from Chic on January 24, 2023, 14:59Thank you for the quick reply.
$order_rate = get_post_meta($order_id, '_woocs_order_rate', true); this function is not working for me that is why this division is giving INF in $order_total
$order_total = $order_data['total']/$order_rate;
I checked in the database table, meta_value is there against this order. What could be the reason?
Just below this line I am calling another get_post_meta for another meta_key which is working well.Please guide.
Thank you for the quick reply.
$order_rate = get_post_meta($order_id, '_woocs_order_rate', true); this function is not working for me that is why this division is giving INF in $order_total
$order_total = $order_data['total']/$order_rate;
I checked in the database table, meta_value is there against this order. What could be the reason?
 Just below this line I am calling another get_post_meta for another meta_key which is working well.
Please guide.
Quote from Chic on January 25, 2023, 07:16Maybe it is because the sequence of the function, i.e the value is not there at the time i am trying to get the post meta value.
I am trying to get post meta on this function/hook:add_action( 'woocommerce_order_status_changed', 'bacs_cheque_cod_payment_complete', 10, 4 );
function bacs_cheque_cod_payment_complete( $order_id, $old_status, $new_status, $order ) {... $order_rate = get_post_meta( $order_id, '_woocs_order_rate', true); ...}
Letme know if I need to change the priority / order or something else
Maybe it is because the sequence of the function, i.e the value is not there at the time i am trying to get the post meta value.
 I am trying to get post meta on this function/hook:
add_action( 'woocommerce_order_status_changed', 'bacs_cheque_cod_payment_complete', 10, 4 );
function bacs_cheque_cod_payment_complete( $order_id, $old_status, $new_status, $order ) {... $order_rate = get_post_meta( $order_id, '_woocs_order_rate', true); ...}
Letme know if I need to change the priority / order or something else
Quote from Pablo Borysenco on January 25, 2023, 12:14Hello
Please drop me code which you use to display the amount (together with my code)
Hello
Please drop me code which you use to display the amount (together with my code)
Quote from Chic on January 25, 2023, 12:36/*Added by Jafer Balti for Auto filling Dispatch Google sheet + Auto stock request email*/
add_action( 'woocommerce_order_status_changed', 'bacs_cheque_cod_payment_complete', 12, 4 );
function bacs_cheque_cod_payment_complete( $order_id, $old_status, $new_status, $order ) {
if( ($old_status == 'pending' && $new_status == 'processing') || (in_array( $order->get_payment_method(), array('bacs', 'cheque', 'cod')) && $new_status == 'processing')) {
google_sheet_and_auto_stock_request_mail($order_id);
}
}function google_sheet_and_auto_stock_request_mail($order_id){
global $wpdb;
$order = new WC_Order($order_id);
$order_data = $order->get_data();//$_order_currency = get_post_meta($order_id, '_order_currency', true);
$order_rate = get_post_meta( $order_id, '_woocs_order_rate', true); //this is not working
if(!$order_rate) $order_rate=1;
$order_total = round($order_data['total']/$order_rate, 2);$sale_location = get_post_meta( $order_id, '_referrer', true ); //this one is working fine
if(empty($sale_location)) $sale_location = 'Online';.....
/*Added by Jafer Balti for Auto filling Dispatch Google sheet + Auto stock request email*/
 add_action( 'woocommerce_order_status_changed', 'bacs_cheque_cod_payment_complete', 12, 4 );
 function bacs_cheque_cod_payment_complete( $order_id, $old_status, $new_status, $order ) {
 if( ($old_status == 'pending' && $new_status == 'processing') || (in_array( $order->get_payment_method(), array('bacs', 'cheque', 'cod')) && $new_status == 'processing')) {
 google_sheet_and_auto_stock_request_mail($order_id);
 }
 }
function google_sheet_and_auto_stock_request_mail($order_id){
 global $wpdb;
 $order = new WC_Order($order_id);
 $order_data = $order->get_data();
//$_order_currency = get_post_meta($order_id, '_order_currency', true);
 $order_rate = get_post_meta( $order_id, '_woocs_order_rate', true); //this is not working
 if(!$order_rate) $order_rate=1;
 $order_total = round($order_data['total']/$order_rate, 2);
$sale_location = get_post_meta( $order_id, '_referrer', true ); //this one is working fine
 if(empty($sale_location)) $sale_location = 'Online';
.....
Quote from Pablo Borysenco on January 25, 2023, 13:45So you can't get any meta data? I mean - get_post_meta($order_id, '_order_currency', true); - in this case, then you can try to get the current rate
global $WOOCS;
$currencies = $WOOCS->get_currencies();
if (!$order_rate) {
if (isset($currencies[$_order_currency])) {
$order_rate = $currencies[$_order_currency]['rate'];
}Do you use new woocommerce feature - https://c2n.me/4hFrgkh.png
So you can't get any meta data? I mean - get_post_meta($order_id, '_order_currency', true); - in this case, then you can try to get the current rate
global $WOOCS;
$currencies = $WOOCS->get_currencies();
if (!$order_rate) {
 if (isset($currencies[$_order_currency])) {
 $order_rate = $currencies[$_order_currency]['rate'];
 }
Do you use new woocommerce feature - https://c2n.me/4hFrgkh.png
Quote from Chic on January 26, 2023, 09:55Thank you Pablo,
It solved my problem.
Thank you Pablo,
It solved my problem.
Quote from Pablo Borysenco on January 26, 2023, 12:00Great! Welcome;)
Great! Welcome;)
