From f73c912945cc61b3ded3681f609e76c0d37a6efb Mon Sep 17 00:00:00 2001 From: rockstardev Date: Sat, 8 Aug 2020 11:14:45 -0500 Subject: [PATCH] Simplifying script by getting variables from Shopify object --- .../wwwroot/shopify/btcpay-shopify-checkout.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/BTCPayServer/wwwroot/shopify/btcpay-shopify-checkout.js b/BTCPayServer/wwwroot/shopify/btcpay-shopify-checkout.js index c736b9315..a4d8c494c 100644 --- a/BTCPayServer/wwwroot/shopify/btcpay-shopify-checkout.js +++ b/BTCPayServer/wwwroot/shopify/btcpay-shopify-checkout.js @@ -8,9 +8,6 @@ @@ -19,6 +16,10 @@ */ ! function () { + // extracted from shopify initialized page + const shopify_price = Shopify.checkout.payment_due; + const shopify_currency = Shopify.checkout.currency; + "use strict"; const pageElements = document.querySelector.bind(document), insertElement = (document.querySelectorAll.bind(document), @@ -81,11 +82,6 @@ pageItems.orderConfirmedDescription && (pageItems.orderConfirmedDescription.style.display = "none"), buttonElement = document.createElement("div"); - const priceElement = pageItems.finalPrice || pageItems.price; - var price = priceElement.innerText.replace(DEFAULT_CURRENCY_SYMBOL, "").replace(THOUSAND_DELIMITER, ""); - if (THOUSAND_DELIMITER === ".") { - price = price.replace(",", "."); // 5.000,00 needs to become 5000.00 - } const orderId = pageItems.orderNumber.innerText.replace("Order #", ""); const url = BTCPAYSERVER_URL + "/invoices" + "?storeId=" + STORE_ID + "&orderId=" + orderId + "&status=complete"; @@ -116,8 +112,8 @@ BTCPAYSERVER_URL, STORE_ID, { - price: price, - currency: DEFAULT_CURRENCY, + price: shopify_price, + currency: shopify_currency, orderId: orderId } )