Skip to content

Instantly share code, notes, and snippets.

@nord
Last active November 13, 2020 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nord/5c693ada2790cf03d44b94fd32fb6cea to your computer and use it in GitHub Desktop.
Save nord/5c693ada2790cf03d44b94fd32fb6cea to your computer and use it in GitHub Desktop.
Integration between Sufio and Bold Multi-Currency app to enable multi-currency support and create invoices in correct currencies. Read more at https://sufio.com/articles/shopify/create-invoices-from-orders/multiple-currencies/
<!-- Integration between Sufio and Bold Multi-Currency app to automatically create invoices in correct currencies. Used by Sufio for Shopify app (sufio.com/shopify). -->
<div class="invoice-currency-container" style="display:none;">
<span class=money id="currency-rate">1.00</span>
<input type="hidden" id="invoice-currency" name="attributes[Invoice Currency]" value="" />
<input type="hidden" id="invoice-currency-rate" name="attributes[Invoice Currency Rate]" value="" />
</div>
<script type="text/javascript">
updateInvoiceCurrency = function() {
$("input#invoice-currency").val(window.BOLDCURRENCY.currentCurrency);
$("input#invoice-currency-rate").val(window.BOLDCURRENCY.rateInfo[window.BOLDCURRENCY.currentCurrency].rate);
};
$(window).on("load", function() {
updateInvoiceCurrency();
});
var observerTarget = $("span#currency-rate")[0];
var observerConfig = { attributes: true, childList: true, characterData: true };
var observer = new MutationObserver(function( mutations ) {
mutations.forEach(function( mutation ) {
updateInvoiceCurrency();
});
});
observer.observe(observerTarget, observerConfig);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment