Change
This endpoint is used to change the currency of a merchant's store and to represent prices for the products. Although the store payouts can be in a different currency, the customer can choose any of the currencies mentioned in the currency selection to display the prices.
:::tip
The change endpoint has been implemented in the Localization Web Component, and It's all setup to save developer's time and effort.
:::
Payload
Response
Usage
To perform the action of changing the store's currency, the developer may call the change()
method as below.
salla.currency.change({ currency_code: "SAR") }).then((response) => {
/* add your code here */
});
// TIP: short version
salla.currency.change("SAR").then((response) => {
/* add your code here */
});
Events
This endpoint may trigger two events, the onChanged and onFailed events.
onChanged
This event is triggered when changing the store's currency is done without having any errors coming back from the backend.
salla.event.currency.onChanged((response) => {
console.log(response)
});
onFailed
This event is triggered when changing the store's currency is not completed and an error has occurred.
```js
salla.event.currency.onFailed((errorMessage) => {
console.log(errorMessage)
});