vendredi 31 janvier 2020

Wordpress - define variable with IF Statement

I've got an ACF Advanced custom field for currency where the user can select currency from the available USD, GBP & EUR select dropdown.

Based on the selection I want to show the currency sign.

I'm trying to define the $price_currency variable that I can then use in my output echo like this: echo '<span>' . $price_currency . '</span>';

This is my current code:

$price_currency = {
      if(get_field('ktrr_ktcamp_price') == "USD");
      echo '&dollar;';
    } elseif(get_field('ktrr_ktcamp_price') == "GBP");
      echo '&pound;';
    } elseif(get_field('ktrr_ktcamp_price') == "EUR");
      echo '&euro;';
}

But I'm getting syntax errors.

What am I doing wrong here?

Aucun commentaire:

Enregistrer un commentaire