Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support laverdervu

    (@laverdervu)

    Hi,

    Can you explain more clearly? I can’t catch your meaning.

    Thread Starter Hanz17

    (@hanz17)

    Hi,

    ok. I need this custom function in template functions.

    IF ($currency == 'EUR') 
    {
      //do something
    }
    else 
    {
      //do something
    }

    But I don’t know how to get the currently selected currency. Is that understandable now?

    Thank you very much.
    Jan

    Hi Jan,
    Please use this:

    if ( class_exists( 'WOOMULTI_CURRENCY_F_Data' ) ) {
    	$currency_data_obj = new WOOMULTI_CURRENCY_F_Data();
    	$current_currency  = $currency_data_obj->get_current_currency();
    }

    Best regards

    Thread Starter Hanz17

    (@hanz17)

    Hi,

    thank you for your help, but it isn′t work :/.

    function test() {
    	
    	if ( class_exists( 'WOOMULTI_CURRENCY_F_Data' ) ) 
    	{
    		$currency_data_obj = new WOOMULTI_CURRENCY_F_Data();
    		$current_currency = $currency_data_obj->get_current_currency();
    		echo "Currency is: ".$current_currency;
    	} 
    	else 
    	{
    		echo "Currency does not load";
    	}
    }
    add_action('wp_footer', 'test');

    The condition always ends in a state that the class does not exist. I’m using the PRO version, isn’t that a problem?

    Are you using free or premium version?

    Thread Starter Hanz17

    (@hanz17)

    I’m using the premium version.

    Ok please create your topic at https://villatheme.com/supports/forum/plugins/woo-multi-currency/ next time you have any problems.

    Here’s the code for Pro version:

    function test() {
    
    	if ( class_exists( 'WOOMULTI_CURRENCY_F_Data' ) )
    	{
    		$currency_data_obj = new WOOMULTI_CURRENCY_Data();
    		$current_currency = $currency_data_obj->get_current_currency();
    		echo "Currency is: ".$current_currency;
    	}
    	else
    	{
    		echo "Currency does not load";
    	}
    }
    Thread Starter Hanz17

    (@hanz17)

    Oh, it works :-).

    Thank you very much for support.
    Jan

    You’re welcome.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Get the current currency in a custom function’ is closed to new replies.