From 0b2015bfbea8f5b1cc1f5c97b572bb41f4c446c3 Mon Sep 17 00:00:00 2001 From: rheber Date: Fri, 17 May 2024 14:18:23 +1000 Subject: [PATCH] pass application key --- spiff-connect/public/js/create-design-button.js | 9 +++++---- spiff-connect/spiff-connect.php | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/spiff-connect/public/js/create-design-button.js b/spiff-connect/public/js/create-design-button.js index b9a4c88..184bb5e 100644 --- a/spiff-connect/public/js/create-design-button.js +++ b/spiff-connect/public/js/create-design-button.js @@ -3,7 +3,7 @@ const htmlDecode = input => { return document.documentElement.textContent; }; -const spiffAppendCreateDesignButton = (wooProductId, integrationProductId, currencyCode, redirectUrl, buttonConfig) => { +const spiffAppendCreateDesignButton = (wooProductId, integrationProductId, currencyCode, redirectUrl, buttonConfig, applicationKey) => { const product = new window.Spiff.IntegrationProduct(integrationProductId); const buttonClass = "test-create-design"; @@ -13,17 +13,18 @@ const spiffAppendCreateDesignButton = (wooProductId, integrationProductId, curre const button = createButton(buttonConfig.personalizeButtonText, buttonConfig, buttonClass); container.appendChild(button); - button.onclick = () => showSpiffTransaction(product, currencyCode, wooProductId, redirectUrl); + button.onclick = () => showSpiffTransaction(product, currencyCode, wooProductId, redirectUrl, applicationKey); }); }); product.confirmActive(); }; -const showSpiffTransaction = ( product, currencyCode, wooProductId, redirectUrl) => { +const showSpiffTransaction = (product, currencyCode, wooProductId, redirectUrl, applicationKey) => { const hostedExperienceOptions = { presentmentCurrency: currencyCode, - product: product, + product, + applicationKey: applicationKey ?? undefined, }; const hostedExperience = new window.Spiff.HostedExperience(hostedExperienceOptions); hostedExperience.on("complete", async (result) => { diff --git a/spiff-connect/spiff-connect.php b/spiff-connect/spiff-connect.php index e8b20b5..c52c8aa 100644 --- a/spiff-connect/spiff-connect.php +++ b/spiff-connect/spiff-connect.php @@ -354,7 +354,7 @@ function spiff_append_create_design_button_on_product_page() { 'width' => esc_attr(get_option('spiff_width') ?: "100%"), 'height' => esc_attr(get_option('spiff_height') ?: "50px") )); - + $application_key = esc_js(get_option('spiff_application_key')); if ($product->get_meta('spiff_enabled') === 'yes') { ?> @@ -365,7 +365,8 @@ function spiff_append_create_design_button_on_product_page() { "", "", "", - + , + "" )