import EasyCurrency from '@eastsideco/escshopify/src/plugins/easycurrency/EasyCurrency.js'
EasyCurrency
Extends:
Plugin for automatic currency conversion, tax handling, etc.
Constructor Summary
Public Constructor | ||
public |
Creates a new instance of EasyCurrency. |
Member Summary
Public Members | ||
public |
|
Private Members | ||
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
Method Summary
Public Methods | ||
public |
Adds the current tax rate to the given amount |
|
public |
Convert an amount to another currency. |
|
public |
Format a value as a currency |
|
public |
Returns the active currency. |
|
public |
async getAvailableCurrencies(): String[] Returns the available currency codes. |
|
public |
Returns the current state. |
|
public |
initialize(config: Object | Config) Start running EasyCurrency on the current page. |
|
public |
parse() Attempts to find new money spans on the page. |
|
public |
render() Forces all money spans to re-render. |
|
public |
setActiveCurrency(currency: String) Sets the active currency, and refreshs any money spans. |
|
public |
setCurrencyResolver(resolver: CurrencyResolver) Overrides the default currency resolver, which provides information about the available currencies. |
|
public |
setFormatter(formatter: Formatter) Overrides the default formatter. |
|
public |
setTaxRate(taxRate: type) Sets the current tax rate. |
|
public |
Uses a default GeoserviceResolver as the currency resolver. |
Private Methods | ||
private |
_processElement(el: DOMNode) |
Public Constructors
public constructor() source
Creates a new instance of EasyCurrency. This class is intended to be used as a singleton, and has global side-effects - do not create multiple instances.
Public Members
public selectHelper: SelectHelper source
Private Members
private _moneySpanSet: MoneySpanSet source
private _resolver: CurrencyResolver source
Public Methods
public async addTax(amount: js-money | Number): Promise<js-money> source
Adds the current tax rate to the given amount
public async convert(amount: js-money | Number, to: String, from: null | String): Promise<js-money> source
Convert an amount to another currency.
public format(amount: js-money | Number, currency: String | null): String source
Format a value as a currency
public parse() source
Attempts to find new money spans on the page. Change moneySpanSelectors / moneySpanParser config options to modify how money spans are parsed.
public setActiveCurrency(currency: String) source
Sets the active currency, and refreshs any money spans.
Params:
Name | Type | Attribute | Description |
currency | String | Currency code |
public setCurrencyResolver(resolver: CurrencyResolver) source
Overrides the default currency resolver, which provides information about the available currencies.
Params:
Name | Type | Attribute | Description |
resolver | CurrencyResolver |
Emit:
currencyResolverChanged(resolver) |
public setFormatter(formatter: Formatter) source
Overrides the default formatter.
Params:
Name | Type | Attribute | Description |
formatter | Formatter |
Emit:
formatterChanged(formatter) |
public setTaxRate(taxRate: type) source
Sets the current tax rate.
Params:
Name | Type | Attribute | Description |
taxRate | type | Tax rate as a decimal percentage (i.e. 20% = 0.2) |
Private Methods
private _processElement(el: DOMNode) source
Params:
Name | Type | Attribute | Description |
el | DOMNode | Element to process |