wordpress - woocommerce get_woocommerce_currency_symbol()

ID : 131309

viewed : 7

Tags : wordpresswoocommercewordpress

Top 5 Answer for wordpress - woocommerce get_woocommerce_currency_symbol()

vote vote

91

Your code should work, which means the issue might be in the database. You can check these 2 functions:
get_woocommerce_currency() and get_woocommerce_currency_symbol()
from the WooCommerce docs that shows that you are using the functions correct.

What is left is for you to start some troubleshooting steps to see what causes the error:

What is get_option('woocommerce_currency') returning? If nothing, then you have no currency set and that is why you get nothing from get_woocommerce_currency_symbol();

What happens if you add a currency as a parameter to get_woocommerce_currency_symbol? it gets displayed? something like echo get_woocommerce_currency_symbol("USD");

You should add to your script some error handling lines, to inform the user that he needs to have the currency set before using your extension.

vote vote

88

use this to show price with currency

$product->get_price_html(); 

OR use

echo get_woocommerce_currency_symbol(); 

to show the currency only

vote vote

80

You should always price under wc_price function, it will automatically add currency symbol along with the default span of woo commerce

For ex.. $product_price = 60; echo wc_price($product_price); 
vote vote

66

get_option('woocommerce_currency') 

will help you lot.

vote vote

55

  function get_woocommerce_currency_symbol( $currency = '' ) {          if ( ! $currency ) {              $currency = get_woocommerce_currency();          }           $symbols = apply_filters( 'woocommerce_currency_symbols', array(              'AED' => 'د.إ',               'AFN' => '؋',               'ALL' => 'L',               'AMD' => 'AMD',               'ANG' => 'ƒ',               'AOA' => 'Kz',               'ARS' => '$',               'AUD' => '$',               'AWG' => 'ƒ',               'AZN' => 'AZN',               'BAM' => 'KM',               'BBD' => '$',               'BDT' => '৳ ',               'BGN' => 'лв.',               'BHD' => '.د.ب',               'BIF' => 'Fr',               'BMD' => '$',               'BND' => '$',               'BOB' => 'Bs.',               'BRL' => 'R$',               'BSD' => '$',               'BTC' => '฿',               'BTN' => 'Nu.',               'BWP' => 'P',               'BYR' => 'Br',               'BZD' => '$',               'CAD' => '$',               'CDF' => 'Fr',               'CHF' => 'CHF',               'CLP' => '$',               'CNY' => '¥',               'COP' => '$',               'CRC' => '₡',               'CUC' => '$',               'CUP' => '$',               'CVE' => '$',               'CZK' => 'Kč',               'DJF' => 'Fr',               'DKK' => 'DKK',               'DOP' => 'RD$',               'DZD' => 'د.ج',               'EGP' => 'EGP',               'ERN' => 'Nfk',               'ETB' => 'Br',               'EUR' => '€',               'FJD' => '$',               'FKP' => '£',               'GBP' => '£',               'GEL' => 'ლ',               'GGP' => '£',               'GHS' => '₵',               'GIP' => '£',               'GMD' => 'D',               'GNF' => 'Fr',               'GTQ' => 'Q',               'GYD' => '$',               'HKD' => '$',               'HNL' => 'L',               'HRK' => 'Kn',               'HTG' => 'G',               'HUF' => 'Ft',               'IDR' => 'Rp',               'ILS' => '₪',               'IMP' => '£',               'INR' => '₹',               'IQD' => 'ع.د',               'IRR' => '﷼',               'IRT' => 'تومان',               'ISK' => 'kr.',               'JEP' => '£',               'JMD' => '$',               'JOD' => 'د.ا',               'JPY' => '¥',               'KES' => 'KSh',               'KGS' => 'сом',               'KHR' => '៛',               'KMF' => 'Fr',               'KPW' => '₩',               'KRW' => '₩',               'KWD' => 'د.ك',               'KYD' => '$',               'KZT' => 'KZT',               'LAK' => '₭',               'LBP' => 'ل.ل',               'LKR' => 'රු',               'LRD' => '$',               'LSL' => 'L',               'LYD' => 'ل.د',               'MAD' => 'د.م.',               'MDL' => 'MDL',               'MGA' => 'Ar',               'MKD' => 'ден',               'MMK' => 'Ks',               'MNT' => '₮',               'MOP' => 'P',               'MRO' => 'UM',               'MUR' => '₨',               'MVR' => '.ރ',               'MWK' => 'MK',               'MXN' => '$',               'MYR' => 'RM',               'MZN' => 'MT',               'NAD' => '$',               'NGN' => '₦',               'NIO' => 'C$',               'NOK' => 'kr',               'NPR' => '₨',               'NZD' => '$',               'OMR' => 'ر.ع.',               'PAB' => 'B/.',               'PEN' => 'S/.',               'PGK' => 'K',               'PHP' => '₱',               'PKR' => '₨',               'PLN' => 'zł',               'PRB' => 'р.',               'PYG' => '₲',               'QAR' => 'ر.ق',               'RMB' => '¥',               'RON' => 'lei',               'RSD' => 'дин.',               'RUB' => '₽',               'RWF' => 'Fr',               'SAR' => 'ر.س',               'SBD' => '$',               'SCR' => '₨',               'SDG' => 'ج.س.',               'SEK' => 'kr',               'SGD' => '$',               'SHP' => '£',               'SLL' => 'Le',               'SOS' => 'Sh',               'SRD' => '$',               'SSP' => '£',               'STD' => 'Db',               'SYP' => 'ل.س',               'SZL' => 'L',               'THB' => '฿',               'TJS' => 'ЅМ',               'TMT' => 'm',               'TND' => 'د.ت',               'TOP' => 'T$',               'TRY' => '₺',               'TTD' => '$',               'TWD' => 'NT$',               'TZS' => 'Sh',               'UAH' => '₴',               'UGX' => 'UGX',               'USD' => '$',               'UYU' => '$',               'UZS' => 'UZS',               'VEF' => 'Bs F',               'VND' => '₫',               'VUV' => 'Vt',               'WST' => 'T',               'XAF' => 'Fr',               'XCD' => '$',               'XOF' => 'Fr',               'XPF' => 'Fr',               'YER' => '﷼',               'ZAR' => 'R',               'ZMW' => 'ZK',        ) );           $currency_symbol = isset( $symbols[ $currency ] ) ? $symbols[ $currency ] : '';           return apply_filters( 'woocommerce_currency_symbol', $currency_symbol, $currency );      }      [1]: http://woocommerce.wp-a2z.org/oik_api/get_woocommerce_currency_symbol/ 

Top 3 video Explaining wordpress - woocommerce get_woocommerce_currency_symbol()

Related QUESTION?