Add the ability to search for a currency by ISO code (#45512)

* Fix - #33503

Added ISO code along with the string. So it can be searched by using country code.

* Fixing linting issues

Added space with single quote to fix linting issue.

* fix linting issues

* add changelog file

* use emdash for separating data

* update test to new format

* include ISO code in settings test fixture

---------

Co-authored-by: daniyal.ahmad1992@gmail.com <daniyal.ahmad1992@gmail.com>
This commit is contained in:
Leif Singer 2024-03-12 17:32:32 +01:00 committed by GitHub
parent 1c068ce3a4
commit a917efc44e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 169 additions and 165 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Add the ability to search for a currency by ISO code.

View File

@ -36,7 +36,7 @@ class WC_Settings_General extends WC_Settings_Page {
$currency_code_options = get_woocommerce_currencies();
foreach ( $currency_code_options as $code => $name ) {
$currency_code_options[ $code ] = $name . ' (' . get_woocommerce_currency_symbol( $code ) . ')';
$currency_code_options[ $code ] = $name . ' (' . get_woocommerce_currency_symbol( $code ) . ')' . esc_html( $code );
}
$settings =

View File

@ -8,168 +8,168 @@
*/
const currencies = {
AED: 'United Arab Emirates dirham (&#x62f;.&#x625;)',
AFN: 'Afghan afghani (&#x60b;)',
ALL: 'Albanian lek (L)',
AMD: 'Armenian dram (AMD)',
ANG: 'Netherlands Antillean guilder (&fnof;)',
AOA: 'Angolan kwanza (Kz)',
ARS: 'Argentine peso (&#36;)',
AUD: 'Australian dollar (&#36;)',
AWG: 'Aruban florin (Afl.)',
AZN: 'Azerbaijani manat (&#8380;)',
BAM: 'Bosnia and Herzegovina convertible mark (KM)',
BBD: 'Barbadian dollar (&#36;)',
BDT: 'Bangladeshi taka (&#2547;&nbsp;)',
BGN: 'Bulgarian lev (&#1083;&#1074;.)',
BHD: 'Bahraini dinar (.&#x62f;.&#x628;)',
BIF: 'Burundian franc (Fr)',
BMD: 'Bermudian dollar (&#36;)',
BND: 'Brunei dollar (&#36;)',
BOB: 'Bolivian boliviano (Bs.)',
BRL: 'Brazilian real (&#82;&#36;)',
BSD: 'Bahamian dollar (&#36;)',
BTC: 'Bitcoin (&#3647;)',
BTN: 'Bhutanese ngultrum (Nu.)',
BWP: 'Botswana pula (P)',
BYR: 'Belarusian ruble (old) (Br)',
BYN: 'Belarusian ruble (Br)',
BZD: 'Belize dollar (&#36;)',
CAD: 'Canadian dollar (&#36;)',
CDF: 'Congolese franc (Fr)',
CHF: 'Swiss franc (&#67;&#72;&#70;)',
CLP: 'Chilean peso (&#36;)',
CNY: 'Chinese yuan (&yen;)',
COP: 'Colombian peso (&#36;)',
CRC: 'Costa Rican col&oacute;n (&#x20a1;)',
CUC: 'Cuban convertible peso (&#36;)',
CUP: 'Cuban peso (&#36;)',
CVE: 'Cape Verdean escudo (&#36;)',
CZK: 'Czech koruna (&#75;&#269;)',
DJF: 'Djiboutian franc (Fr)',
DKK: 'Danish krone (kr.)',
DOP: 'Dominican peso (RD&#36;)',
DZD: 'Algerian dinar (&#x62f;.&#x62c;)',
EGP: 'Egyptian pound (EGP)',
ERN: 'Eritrean nakfa (Nfk)',
ETB: 'Ethiopian birr (Br)',
EUR: 'Euro (&euro;)',
FJD: 'Fijian dollar (&#36;)',
FKP: 'Falkland Islands pound (&pound;)',
GBP: 'Pound sterling (&pound;)',
GEL: 'Georgian lari (&#x20be;)',
GGP: 'Guernsey pound (&pound;)',
GHS: 'Ghana cedi (&#x20b5;)',
GIP: 'Gibraltar pound (&pound;)',
GMD: 'Gambian dalasi (D)',
GNF: 'Guinean franc (Fr)',
GTQ: 'Guatemalan quetzal (Q)',
GYD: 'Guyanese dollar (&#36;)',
HKD: 'Hong Kong dollar (&#36;)',
HNL: 'Honduran lempira (L)',
HRK: 'Croatian kuna (kn)',
HTG: 'Haitian gourde (G)',
HUF: 'Hungarian forint (&#70;&#116;)',
IDR: 'Indonesian rupiah (Rp)',
ILS: 'Israeli new shekel (&#8362;)',
IMP: 'Manx pound (&pound;)',
INR: 'Indian rupee (&#8377;)',
IQD: 'Iraqi dinar (&#x62f;.&#x639;)',
IRR: 'Iranian rial (&#xfdfc;)',
IRT: 'Iranian toman (&#x062A;&#x0648;&#x0645;&#x0627;&#x0646;)',
ISK: 'Icelandic kr&oacute;na (kr.)',
JEP: 'Jersey pound (&pound;)',
JMD: 'Jamaican dollar (&#36;)',
JOD: 'Jordanian dinar (&#x62f;.&#x627;)',
JPY: 'Japanese yen (&yen;)',
KES: 'Kenyan shilling (KSh)',
KGS: 'Kyrgyzstani som (&#x441;&#x43e;&#x43c;)',
KHR: 'Cambodian riel (&#x17db;)',
KMF: 'Comorian franc (Fr)',
KPW: 'North Korean won (&#x20a9;)',
KRW: 'South Korean won (&#8361;)',
KWD: 'Kuwaiti dinar (&#x62f;.&#x643;)',
KYD: 'Cayman Islands dollar (&#36;)',
KZT: 'Kazakhstani tenge (&#8376;)',
LAK: 'Lao kip (&#8365;)',
LBP: 'Lebanese pound (&#x644;.&#x644;)',
LKR: 'Sri Lankan rupee (&#xdbb;&#xdd4;)',
LRD: 'Liberian dollar (&#36;)',
LSL: 'Lesotho loti (L)',
MAD: 'Moroccan dirham (&#x62f;.&#x645;.)',
MDL: 'Moldovan leu (MDL)',
MGA: 'Malagasy ariary (Ar)',
MKD: 'Macedonian denar (&#x434;&#x435;&#x43d;)',
MMK: 'Burmese kyat (Ks)',
MNT: 'Mongolian t&ouml;gr&ouml;g (&#x20ae;)',
MOP: 'Macanese pataca (P)',
MRU: 'Mauritanian ouguiya (UM)',
MUR: 'Mauritian rupee (&#x20a8;)',
MVR: 'Maldivian rufiyaa (.&#x783;)',
MWK: 'Malawian kwacha (MK)',
MXN: 'Mexican peso (&#36;)',
MYR: 'Malaysian ringgit (&#82;&#77;)',
MZN: 'Mozambican metical (MT)',
NAD: 'Namibian dollar (N&#36;)',
NGN: 'Nigerian naira (&#8358;)',
NIO: 'Nicaraguan c&oacute;rdoba (C&#36;)',
NOK: 'Norwegian krone (&#107;&#114;)',
NPR: 'Nepalese rupee (&#8360;)',
NZD: 'New Zealand dollar (&#36;)',
OMR: 'Omani rial (&#x631;.&#x639;.)',
PAB: 'Panamanian balboa (B/.)',
PEN: 'Sol (S/)',
PGK: 'Papua New Guinean kina (K)',
PHP: 'Philippine peso (&#8369;)',
PKR: 'Pakistani rupee (&#8360;)',
PLN: 'Polish z&#x142;oty (&#122;&#322;)',
PRB: 'Transnistrian ruble (&#x440;.)',
PYG: 'Paraguayan guaran&iacute; (&#8370;)',
QAR: 'Qatari riyal (&#x631;.&#x642;)',
RON: 'Romanian leu (lei)',
RSD: 'Serbian dinar (&#1088;&#1089;&#1076;)',
RUB: 'Russian ruble (&#8381;)',
RWF: 'Rwandan franc (Fr)',
SAR: 'Saudi riyal (&#x631;.&#x633;)',
SBD: 'Solomon Islands dollar (&#36;)',
SCR: 'Seychellois rupee (&#x20a8;)',
SDG: 'Sudanese pound (&#x62c;.&#x633;.)',
SEK: 'Swedish krona (&#107;&#114;)',
SGD: 'Singapore dollar (&#36;)',
SHP: 'Saint Helena pound (&pound;)',
SLL: 'Sierra Leonean leone (Le)',
SOS: 'Somali shilling (Sh)',
SRD: 'Surinamese dollar (&#36;)',
SSP: 'South Sudanese pound (&pound;)',
STN: 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe dobra (Db)',
SYP: 'Syrian pound (&#x644;.&#x633;)',
SZL: 'Swazi lilangeni (E)',
THB: 'Thai baht (&#3647;)',
TJS: 'Tajikistani somoni (&#x405;&#x41c;)',
TMT: 'Turkmenistan manat (m)',
TND: 'Tunisian dinar (&#x62f;.&#x62a;)',
TOP: 'Tongan pa&#x2bb;anga (T&#36;)',
TRY: 'Turkish lira (&#8378;)',
TTD: 'Trinidad and Tobago dollar (&#36;)',
TWD: 'New Taiwan dollar (&#78;&#84;&#36;)',
TZS: 'Tanzanian shilling (Sh)',
UAH: 'Ukrainian hryvnia (&#8372;)',
UGX: 'Ugandan shilling (UGX)',
USD: 'United States (US) dollar (&#36;)',
UYU: 'Uruguayan peso (&#36;)',
UZS: 'Uzbekistani som (UZS)',
VEF: 'Venezuelan bol&iacute;var (20082018) (Bs F)',
VES: 'Venezuelan bol&iacute;var (Bs.)',
VND: 'Vietnamese &#x111;&#x1ed3;ng (&#8363;)',
VUV: 'Vanuatu vatu (Vt)',
WST: 'Samoan t&#x101;l&#x101; (T)',
XAF: 'Central African CFA franc (CFA)',
XCD: 'East Caribbean dollar (&#36;)',
XOF: 'West African CFA franc (CFA)',
XPF: 'CFP franc (Fr)',
YER: 'Yemeni rial (&#xfdfc;)',
ZAR: 'South African rand (&#82;)',
ZMW: 'Zambian kwacha (ZK)',
AED: 'United Arab Emirates dirham (&#x62f;.&#x625;) — AED',
AFN: 'Afghan afghani (&#x60b;) — AFN',
ALL: 'Albanian lek (L) — ALL',
AMD: 'Armenian dram (AMD) — AMD',
ANG: 'Netherlands Antillean guilder (&fnof;) — ANG',
AOA: 'Angolan kwanza (Kz) — AOA',
ARS: 'Argentine peso (&#36;) — ARS',
AUD: 'Australian dollar (&#36;) — AUD',
AWG: 'Aruban florin (Afl.) — AWG',
AZN: 'Azerbaijani manat (&#8380;) — AZN',
BAM: 'Bosnia and Herzegovina convertible mark (KM) — BAM',
BBD: 'Barbadian dollar (&#36;) — BBD',
BDT: 'Bangladeshi taka (&#2547;&nbsp;) — BDT',
BGN: 'Bulgarian lev (&#1083;&#1074;.) — BGN',
BHD: 'Bahraini dinar (.&#x62f;.&#x628;) — BHD',
BIF: 'Burundian franc (Fr) — BIF',
BMD: 'Bermudian dollar (&#36;) — BMD',
BND: 'Brunei dollar (&#36;) — BND',
BOB: 'Bolivian boliviano (Bs.) — BOB',
BRL: 'Brazilian real (&#82;&#36;) — BRL',
BSD: 'Bahamian dollar (&#36;) — BSD',
BTC: 'Bitcoin (&#3647;) — BTC',
BTN: 'Bhutanese ngultrum (Nu.) — BTN',
BWP: 'Botswana pula (P) — BWP',
BYR: 'Belarusian ruble (old) (Br) — BYR',
BYN: 'Belarusian ruble (Br) — BYN',
BZD: 'Belize dollar (&#36;) — BZD',
CAD: 'Canadian dollar (&#36;) — CAD',
CDF: 'Congolese franc (Fr) — CDF',
CHF: 'Swiss franc (&#67;&#72;&#70;) — CHF',
CLP: 'Chilean peso (&#36;) — CLP',
CNY: 'Chinese yuan (&yen;) — CNY',
COP: 'Colombian peso (&#36;) — COP',
CRC: 'Costa Rican col&oacute;n (&#x20a1;) — CRC',
CUC: 'Cuban convertible peso (&#36;) — CUC',
CUP: 'Cuban peso (&#36;) — CUP',
CVE: 'Cape Verdean escudo (&#36;) — CVE',
CZK: 'Czech koruna (&#75;&#269;) — CZK',
DJF: 'Djiboutian franc (Fr) — DJF',
DKK: 'Danish krone (kr.) — DKK',
DOP: 'Dominican peso (RD&#36;) — DOP',
DZD: 'Algerian dinar (&#x62f;.&#x62c;) — DZD',
EGP: 'Egyptian pound (EGP) — EGP',
ERN: 'Eritrean nakfa (Nfk) — ERN',
ETB: 'Ethiopian birr (Br) — ETB',
EUR: 'Euro (&euro;) — EUR',
FJD: 'Fijian dollar (&#36;) — FJD',
FKP: 'Falkland Islands pound (&pound;) — FKP',
GBP: 'Pound sterling (&pound;) — GBP',
GEL: 'Georgian lari (&#x20be;) — GEL',
GGP: 'Guernsey pound (&pound;) — GGP',
GHS: 'Ghana cedi (&#x20b5;) — GHS',
GIP: 'Gibraltar pound (&pound;) — GIP',
GMD: 'Gambian dalasi (D) — GMD',
GNF: 'Guinean franc (Fr) — GNF',
GTQ: 'Guatemalan quetzal (Q) — GTQ',
GYD: 'Guyanese dollar (&#36;) — GYD',
HKD: 'Hong Kong dollar (&#36;) — HKD',
HNL: 'Honduran lempira (L) — HNL',
HRK: 'Croatian kuna (kn) — HRK',
HTG: 'Haitian gourde (G) — HTG',
HUF: 'Hungarian forint (&#70;&#116;) — HUF',
IDR: 'Indonesian rupiah (Rp) — IDR',
ILS: 'Israeli new shekel (&#8362;) — ILS',
IMP: 'Manx pound (&pound;) — IMP',
INR: 'Indian rupee (&#8377;) — INR',
IQD: 'Iraqi dinar (&#x62f;.&#x639;) — IQD',
IRR: 'Iranian rial (&#xfdfc;) — IRR',
IRT: 'Iranian toman (&#x062A;&#x0648;&#x0645;&#x0627;&#x0646;) — IRT',
ISK: 'Icelandic kr&oacute;na (kr.) — ISK',
JEP: 'Jersey pound (&pound;) — JEP',
JMD: 'Jamaican dollar (&#36;) — JMD',
JOD: 'Jordanian dinar (&#x62f;.&#x627;) — JOD',
JPY: 'Japanese yen (&yen;) — JPY',
KES: 'Kenyan shilling (KSh) — KES',
KGS: 'Kyrgyzstani som (&#x441;&#x43e;&#x43c;) — KGS',
KHR: 'Cambodian riel (&#x17db;) — KHR',
KMF: 'Comorian franc (Fr) — KMF',
KPW: 'North Korean won (&#x20a9;) — KPW',
KRW: 'South Korean won (&#8361;) — KRW',
KWD: 'Kuwaiti dinar (&#x62f;.&#x643;) — KWD',
KYD: 'Cayman Islands dollar (&#36;) — KYD',
KZT: 'Kazakhstani tenge (&#8376;) — KZT',
LAK: 'Lao kip (&#8365;) — LAK',
LBP: 'Lebanese pound (&#x644;.&#x644;) — LBP',
LKR: 'Sri Lankan rupee (&#xdbb;&#xdd4;) — LKR',
LRD: 'Liberian dollar (&#36;) — LRD',
LSL: 'Lesotho loti (L) — LSL',
MAD: 'Moroccan dirham (&#x62f;.&#x645;.) — MAD',
MDL: 'Moldovan leu (MDL) — MDL',
MGA: 'Malagasy ariary (Ar) — MGA',
MKD: 'Macedonian denar (&#x434;&#x435;&#x43d;) — MKD',
MMK: 'Burmese kyat (Ks) — MMK',
MNT: 'Mongolian t&ouml;gr&ouml;g (&#x20ae;) — MNT',
MOP: 'Macanese pataca (P) — MOP',
MRU: 'Mauritanian ouguiya (UM) — MRU',
MUR: 'Mauritian rupee (&#x20a8;) — MUR',
MVR: 'Maldivian rufiyaa (.&#x783;) — MVR',
MWK: 'Malawian kwacha (MK) — MWK',
MXN: 'Mexican peso (&#36;) — MXN',
MYR: 'Malaysian ringgit (&#82;&#77;) — MYR',
MZN: 'Mozambican metical (MT) — MZN',
NAD: 'Namibian dollar (N&#36;) — NAD',
NGN: 'Nigerian naira (&#8358;) — NGN',
NIO: 'Nicaraguan c&oacute;rdoba (C&#36;) — NIO',
NOK: 'Norwegian krone (&#107;&#114;) — NOK',
NPR: 'Nepalese rupee (&#8360;) — NPR',
NZD: 'New Zealand dollar (&#36;) — NZD',
OMR: 'Omani rial (&#x631;.&#x639;.) — OMR',
PAB: 'Panamanian balboa (B/.) — PAB',
PEN: 'Sol (S/) — PEN',
PGK: 'Papua New Guinean kina (K) — PGK',
PHP: 'Philippine peso (&#8369;) — PHP',
PKR: 'Pakistani rupee (&#8360;) — PKR',
PLN: 'Polish z&#x142;oty (&#122;&#322;) — PLN',
PRB: 'Transnistrian ruble (&#x440;.) — PRB',
PYG: 'Paraguayan guaran&iacute; (&#8370;) — PYG',
QAR: 'Qatari riyal (&#x631;.&#x642;) — QAR',
RON: 'Romanian leu (lei) — RON',
RSD: 'Serbian dinar (&#1088;&#1089;&#1076;) — RSD',
RUB: 'Russian ruble (&#8381;) — RUB',
RWF: 'Rwandan franc (Fr) — RWF',
SAR: 'Saudi riyal (&#x631;.&#x633;) — SAR',
SBD: 'Solomon Islands dollar (&#36;) — SBD',
SCR: 'Seychellois rupee (&#x20a8;) — SCR',
SDG: 'Sudanese pound (&#x62c;.&#x633;.) — SDG',
SEK: 'Swedish krona (&#107;&#114;) — SEK',
SGD: 'Singapore dollar (&#36;) — SGD',
SHP: 'Saint Helena pound (&pound;) — SHP',
SLL: 'Sierra Leonean leone (Le) — SLL',
SOS: 'Somali shilling (Sh) — SOS',
SRD: 'Surinamese dollar (&#36;) — SRD',
SSP: 'South Sudanese pound (&pound;) — SSP',
STN: 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe dobra (Db) — STN',
SYP: 'Syrian pound (&#x644;.&#x633;) — SYP',
SZL: 'Swazi lilangeni (E) — SZL',
THB: 'Thai baht (&#3647;) — THB',
TJS: 'Tajikistani somoni (&#x405;&#x41c;) — TJS',
TMT: 'Turkmenistan manat (m) — TMT',
TND: 'Tunisian dinar (&#x62f;.&#x62a;) — TND',
TOP: 'Tongan pa&#x2bb;anga (T&#36;) — TOP',
TRY: 'Turkish lira (&#8378;) — TRY',
TTD: 'Trinidad and Tobago dollar (&#36;) — TTD',
TWD: 'New Taiwan dollar (&#78;&#84;&#36;) — TWD',
TZS: 'Tanzanian shilling (Sh) — TZS',
UAH: 'Ukrainian hryvnia (&#8372;) — UAH',
UGX: 'Ugandan shilling (UGX) — UGX',
USD: 'United States (US) dollar (&#36;) — USD',
UYU: 'Uruguayan peso (&#36;) — UYU',
UZS: 'Uzbekistani som (UZS) — UZS',
VEF: 'Venezuelan bol&iacute;var (20082018) (Bs F) — VEF',
VES: 'Venezuelan bol&iacute;var (Bs.) — VES',
VND: 'Vietnamese &#x111;&#x1ed3;ng (&#8363;) — VND',
VUV: 'Vanuatu vatu (Vt) — VUV',
WST: 'Samoan t&#x101;l&#x101; (T) — WST',
XAF: 'Central African CFA franc (CFA) — XAF',
XCD: 'East Caribbean dollar (&#36;) — XCD',
XOF: 'West African CFA franc (CFA) — XOF',
XPF: 'CFP franc (Fr) — XPF',
YER: 'Yemeni rial (&#xfdfc;) — YER',
ZAR: 'South African rand (&#82;) — ZAR',
ZMW: 'Zambian kwacha (ZK) — ZMW',
};
const externalCurrencies = {

View File

@ -101,8 +101,8 @@ class WC_Settings_General_Test extends WC_Settings_Unit_Test_Case {
$currencies = $currency_setting['options'];
$expected = array(
'c1' => 'Currency 1 (symbol for c1)',
'c2' => 'Currency 2 (symbol for c2)',
'c1' => 'Currency 1 (symbol for c1) — c1',
'c2' => 'Currency 2 (symbol for c2) — c2',
);
$this->assertEquals( $expected, $currencies );