{"id":108677,"date":"2018-01-11T15:59:56","date_gmt":"2018-01-11T15:59:56","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=108677"},"modified":"2018-01-11T16:01:41","modified_gmt":"2018-01-11T16:01:41","slug":"get-allowed-currencies-having-rates","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/","title":{"rendered":"How to get all the allowed currencies having currency rates."},"content":{"rendered":"<p>Hello everyone, sometimes we need all those currencies that are allowed by admin and also have conversion rates set by the admin.<\/p>\n<p>Following code will help you to achieve this.<\/p>\n<p>First of all, In the Helper construct, add the following code,<\/p>\n<pre class=\"brush:php\">public function __construct(\r\n   \\Magento\\Directory\\Block\\Currency $currency,\r\n   \\Magento\\Framework\\App\\Helper\\Context $context\r\n) {\r\n   $this-&gt;_currency = $currency;\r\n   parent::__construct($context);\r\n}\r\n<\/pre>\n<p>after that, you can write this function to get the currencies codes with their corresponding names as below-<\/p>\n<pre class=\"brush:php\">public function getCurrencies() \/\/this will fetch the allowed currencies for which rates are set\r\n{\r\n    $currencies = $this-&gt;_currency-&gt;getCurrencies();\r\n    $currencyData = [];\r\n    foreach ($currencies as $code =&gt; $currencyName) {\r\n        $currencyData[$code]['code'] = $code;\r\n        $currencyData[$code]['name'] = $currencyName;\r\n    }\r\n    return $currencyData;\r\n}<\/pre>\n<p>if you print $currencyData, it will display the result as you can see in the image-<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-108696\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png\" alt=\"\" width=\"498\" height=\"587\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png 498w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name-211x249.png 211w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name-255x300.png 255w\" sizes=\"(max-width: 498px) 100vw, 498px\" loading=\"lazy\" \/><br \/>\nThis is all for now. Hope this will help.<\/p>\n<p>For any queries, comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello everyone, sometimes we need all those currencies that are allowed by admin and also have conversion rates set by the admin. Following code will help you to achieve this. First of all, In the Helper construct, add the following code, public function __construct( \\Magento\\Directory\\Block\\Currency $currency, \\Magento\\Framework\\App\\Helper\\Context $context ) { $this-&gt;_currency = $currency; parent::__construct($context); } <a href=\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":167,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[6056,6055,2460],"class_list":["post-108677","post","type-post","status-publish","format-standard","hentry","category-magento2","tag-allowed-currencies-having-rates","tag-currencies","tag-magento-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to get all the allowed currencies having currency rates. - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to get all the allowed currencies having currency rates. - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Hello everyone, sometimes we need all those currencies that are allowed by admin and also have conversion rates set by the admin. Following code will help you to achieve this. First of all, In the Helper construct, add the following code, public function __construct( MagentoDirectoryBlockCurrency $currency, MagentoFrameworkAppHelperContext $context ) { $this-&gt;_currency = $currency; parent::__construct($context); } [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-11T15:59:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-11T16:01:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png\" \/>\n<meta name=\"author\" content=\"Hemant Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hemant Jain\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/\"},\"author\":{\"name\":\"Hemant Jain\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6\"},\"headline\":\"How to get all the allowed currencies having currency rates.\",\"datePublished\":\"2018-01-11T15:59:56+00:00\",\"dateModified\":\"2018-01-11T16:01:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/\"},\"wordCount\":99,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png\",\"keywords\":[\"Allowed currencies having rates\",\"Currencies\",\"Magento 2\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/\",\"url\":\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/\",\"name\":\"How to get all the allowed currencies having currency rates. - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png\",\"datePublished\":\"2018-01-11T15:59:56+00:00\",\"dateModified\":\"2018-01-11T16:01:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png\",\"width\":498,\"height\":587},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to get all the allowed currencies having currency rates.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6\",\"name\":\"Hemant Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Hemant Jain\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/hemant-jain591\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to get all the allowed currencies having currency rates. - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/","og_locale":"en_US","og_type":"article","og_title":"How to get all the allowed currencies having currency rates. - Webkul Blog","og_description":"Hello everyone, sometimes we need all those currencies that are allowed by admin and also have conversion rates set by the admin. Following code will help you to achieve this. First of all, In the Helper construct, add the following code, public function __construct( MagentoDirectoryBlockCurrency $currency, MagentoFrameworkAppHelperContext $context ) { $this-&gt;_currency = $currency; parent::__construct($context); } [...]","og_url":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2018-01-11T15:59:56+00:00","article_modified_time":"2018-01-11T16:01:41+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png","type":"","width":"","height":""}],"author":"Hemant Jain","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Hemant Jain","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/"},"author":{"name":"Hemant Jain","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6"},"headline":"How to get all the allowed currencies having currency rates.","datePublished":"2018-01-11T15:59:56+00:00","dateModified":"2018-01-11T16:01:41+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/"},"wordCount":99,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png","keywords":["Allowed currencies having rates","Currencies","Magento 2"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/","url":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/","name":"How to get all the allowed currencies having currency rates. - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png","datePublished":"2018-01-11T15:59:56+00:00","dateModified":"2018-01-11T16:01:41+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/01\/currency-code-with-name.png","width":498,"height":587},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/get-allowed-currencies-having-rates\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to get all the allowed currencies having currency rates."}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/a824ac6c5c14d32569263100b85f47c6","name":"Hemant Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/184358b1c25c580a3e32952605156294dedfff2b8b75bdb2a719c8e6a5d318b6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Hemant Jain"},"url":"https:\/\/webkul.com\/blog\/author\/hemant-jain591\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/108677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/167"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=108677"}],"version-history":[{"count":4,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/108677\/revisions"}],"predecessor-version":[{"id":108699,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/108677\/revisions\/108699"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=108677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=108677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=108677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}