How To: Obtain currency conversion rate through liquid?

How To: Obtain currency conversion rate through liquid?

SGWH
Shopify Partner
7 0 21

We are working on a feature where we want to add support for multi-currency so customers can pay through their local currency.

 

To achieve the functionality, we have a requirement to retrieve currency conversion rate within liquid. We did a lot of R&D and tried possible solutions, however, couldn't succeed.


We found that the rate can be obtained through a piece of JS code: window.Shopify.currency.rate, but this works on the storefront. If we use this way, it will add huge complexity to our code and execution.

 

How can we obtain currency conversion rate through liquid?

Replies 4 (4)

SGSdev
Shopify Partner
18 2 7

I also need to get the currency rate with liquid. @Shopify please respond.

Rose_CWC
Shopify Partner
5 0 0

Did you find a solution for this? Has anything changed?

www.creativewebco.com
vivekrc
Shopify Partner
4 0 1

Hi Rose,

You can update the daily currency rate in metafields via say a script. Then, use Liquid to show these rates and calculate prices.

For instance, the liquid code could look like:

{% assign conversion_rate = shop.metafields.global.usd_to_gbp.value | default: 1.38 %}

{% assign product_price_gbp = product.price | times: conversion_rate %}
{{ product_price_gbp | money_with_currency }}

 

Let me know if you need any help!


Founder - CartKing (https://apps.shopify.com/cartking)
sebastiandev
Shopify Partner
72 1 26

Where can I find currency rate?