-
AuthorPosts
-
July 13, 2024 at 9:37 pm #206872
FADI EDRISParticipantHey Team,
I need help in completing the code for changing the currency price in checkout using the CURCY plugin in which i purchased.
Our checkout page currency is USD, we bought this plugin in order to change the currency on the website from USD to the currency the customer choses.Please see below the code line in which i need to add the automated flat rate variable pulled from plugin within my custom php code.
This is the code I am aiming to use within my website to pull the automated exchange rate from the plugin
(the variable i need from you is the one that pulls the automatic exchange rate):add_filter( ‘raw_woocommerce_price’, ‘change_product_price’, 10, 2 );
function change_product_price( $price, $product ) {if ( is_admin() || ! is_checkout() ) {
return $price;
}
$flat_rate = wc_get_excange_rate ; // In this line i want to pull the exchange rate from the plugin
$billing_country = WC()->customer->get_billing_country() ;
if ( ‘AE’ === $billing_country ) {
return $price * $flat_rate;
} elseif ( ‘QA’ === $billing_country ) {
return $price * $flat_rate;
}
return $price;
}This is the Current code being used while the exchange rate used to multiply the base USD price is manual.
add_filter( ‘raw_woocommerce_price’, ‘change_product_price’, 10, 2 );
function change_product_price( $price, $product ) {if ( is_admin() || ! is_checkout() ) {
return $price;
}
$billing_country = WC()->customer->get_billing_country() ;
if ( ‘AE’ === $billing_country ) {
return $price * 3.67;
} elseif ( ‘QA’ === $billing_country ) {
return $price * 3.64;
}
return $price;
}best regards
-
AuthorPosts
You must be logged in to see replies to this topic. Click here to login or register