[ad_1]
hello i need urgent help plz
im using your plugin and on add to cart im trying to change the price to different currency but before doing that i was trying to fetch data and im getting error undefined class plz tell me what is wrong.
here is my code
add_action('woocommerce_before_calculate_totals', 'convert_cart_prices_to_ron');
function convert_cart_prices_to_ron($cart) {
if (is_admin() && !defined('DOING_AJAX')) return;
$selected_currency = get_woocommerce_currency();
$conversion_rate = 1;
if ($selected_currency != 'RON') {
$currentCurrencyRate = 1;
if(class_exists('WOOMULTI_CURRENCY_Data')) {
$multiCurrencySettings = WOOMULTI_CURRENCY_Data::get_ins();
$wmcCurrencies = $multiCurrencySettings->get_list_currencies();
$currentCurrency = $multiCurrencySettings->get_current_currency();
$currentCurrencyRate = floatval( $wmcCurrencies[ $currentCurrency ]['rate'] );
}
}
foreach ($cart->get_cart() as $cart_item) {
$price = $cart_item['data']->get_price();
$cart_item['data']->set_price($price / $conversion_rate);
}
}
