Shopify autocomplete currency


I just installed Algolia autocomplete on my Shopify website (with default simple theme) and everything seems fine except the $ sign. How to change it to € ?



Can you confirm that your store’s currency is defined as euros?
If it is, then it means that we’re having trouble with your currency format string.
In this case, feel free to edit algolia_init.js, in the last function, and to replace the dollar sign here by an euro sign.

Yes it is : :neutral_face:

Could you click on the Change formatting button there and also send us a screenshot of it?

Here is :wink:

Here is the issue for us. We’re not supporting the {{ amount_with_space_separator }} string.
This is why in algolia_init.js.liquid, you should do this:

  algolia.formatMoney = function formatMoney (cents) {
    var val = (cents / 100.0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
    var format = algolia.money_format;

    // Not necessary, but allows for more risk tolerance if Shopify.formatMoney doesn't work as we want
    var regexp = /^([^{}]*)\{\{amount\}\}([^{}]*)$/;
    if (format.match(regexp)) {
      return format.replace(regexp, "$1" + val + "$2");

    if (!_.isUndefined(Shopify) && !_.isUndefined(Shopify.formatMoney)) {
      return Shopify.formatMoney(cents, format);

    // Replace
    // return '$' + val;
    // with
    return val + '€';

@Jerska I suppose you’re not supporting {{amount_with_comma_separator}} either? I’m having the same exact issue as described above, but we’re using a comma separator for our currencies.
I’m going to edit the algolia_init.js to make it fit what we want so no biggie, but it would be nice to have the docs show what is supported or not :slight_smile: (or is it already and I missed it?)

Actually, if you do have Shopify.formatMoney in your store, it is supported.
It is included in some official Shopify front-end code, which can or not be present in your theme.

For IP reasons, we decided not to fully replicate it, but you can find it there:

Simply put it in a <script> tag, which you’ll need to add before our code in layouts/theme.liquid, like so:

<!-- Other HTML tags -->

// Code goes here

<!-- Algolia head -->