Last active
November 13, 2020 10:32
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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