| 1 |
/** |
| 2 |
* Returns the currency symbol for the globally configured plugin currency. |
| 3 |
* Reads from window.betterPaymentCampaignData.globalCurrency (localized by CPT.php). |
| 4 |
* Falls back to '$' if unavailable or Intl is unsupported. |
| 5 |
*/ |
| 6 |
export function getGlobalCurrencySymbol() { |
| 7 |
const currency = window?.betterPaymentCampaignData?.globalCurrency || 'USD'; |
| 8 |
try { |
| 9 |
return new Intl.NumberFormat( 'en-US', { style: 'currency', currency } ) |
| 10 |
.formatToParts( 0 ) |
| 11 |
.find( ( p ) => p.type === 'currency' )?.value || '$'; |
| 12 |
} catch { |
| 13 |
return '$'; |
| 14 |
} |
| 15 |
} |
| 16 |
|