Both sides previous revisionPrevious revisionNext revision | Previous revision |
v:2.0:multicurrency [2016/10/07 04:48] – [Some Examples of MultiCurrency Usage] adam | v:2.0:multicurrency [2020/04/21 17:30] (current) – [MultiCurrency and Discounts] marija |
---|
| |
===== How Multi-Currency Functionality works in FoxyCart ===== | ===== How Multi-Currency Functionality works in FoxyCart ===== |
Enabling multi-currency for your store doesn't change anything by default. The ''price'' parameter still defaults to your store's default currency, as specified in your store's "settings" page. This is important to note, as FoxyCart will interpret prices without a currency code in this way. | FoxyCart includes multi-currency in a couple ways - both changing the currency of the whole cart and dynamically converting a price from one currency to another. |
| |
There are two parameters that you can use to handle transactions in different currencies: | There are two parameters that you can use to handle transactions in different currencies: ''template_set'' and ''price''. |
* ''template_set'' is passed through as a session-wide variable, as the code of the respective template set as specified in the administration. See the [[v:2.0:template_sets|template sets section]] for more information. | |
* ''price'', appended with a [[http://en.wikipedia.org/wiki/ISO_4217#Active_codes|3-character ISO currency code]], eg: ''&price=15.99usd'' | |
| |
The ''template_set'' is //not product specific//, but rather changes the currency for the customer's cart, for that session. By default for new customers it will be your store's configured locale. You can set it with a normal call to your ''/cart'' endpoint. Note that **changing the ''template_set'' to one with a different locale that the cart is currently set to will empty the cart**. You can, however, add products in the same request that you change the ''template_set'', and they'll be added appropriately. | ==== template_set: session wide locale setting ==== |
| |
If a product is added in a currency that does not match the current locale of the cart (for example, with a store that is set to USD by default, and a product is added to the cart as ''price=50mxn''), the products price will be dynamically converted to the cart currency. The rate used in the conversion is requested from [[http://openexchangerates.org|openexchangerates.org]]. | The [[v:2.0:template_sets|template set]] paramater is passed through as a session-wide variable, as the code of the respective template set as specified in the administration, such as ''&template_set=fr''. The template set is not product specific, but changes the currency (and also possibly language) for the customer's entire cart for that session. View the [[v:2.0:template_sets|template set]] page for details on adding and using the sets for your store. |
| |
| By default, new customers will see a cart in your store's default locale, as set in the ''DEFAULT'' template set (or alternatively from the "store locale" setting on the store's setting page). |
| |
| You can specify a template set with a normal call to your store's ''/cart'' endpoint. Note that changing the ''template_set'' to one with a different locale than the cart is currently set to will empty the cart. You can however add products in the same request that you change the ''template_set'', and they'll be added appropriately. |
| |
| ==== price: per product with currency code appended ==== |
| |
| The currency for a specific product can also be set by appending the 3-character ISO currency code, eg: ''&price=15.99usd'' |
| |
| If a product is added in a currency that does not match the current locale of the cart (for example, with a store that is set to USD, and a product is added to the cart as ''price=50mxn''), the products price will be dynamically converted to the cart currency. If no currency code is appended to a product's price, it will be assumed as the store's default currency, and dynamically converted from that to the current currency of the cart. |
| |
| Dynamic price conversions currently require that a store have at least two different template sets with differing locales be configured. The rate used in the conversion is requested from [[http://openexchangerates.org|openexchangerates.org]]. |
| |
==== Product Option Modifiers ==== | ==== Product Option Modifiers ==== |
</code> | </code> |
| |
This syntax is the same for category discounts and for coupons. This allows setting custom discounts per currency. <wrap tip>If a currency is not included, the discount will not apply.</wrap> This is to prevent discounts from applying that could have significantly wrong values after the conversion math is done. | This syntax is the same for category discounts and for coupons, except you'll put the JSON right in the //coupon// or //discount details// input. This allows setting custom discounts per currency. <wrap tip>If a currency is not included, the discount will not apply.</wrap> This is to prevent discounts from applying that could have significantly wrong values after the conversion math is done. |
| |
==== Some Examples of MultiCurrency Usage ==== | ==== Some Examples of MultiCurrency Usage ==== |