diff --git a/projects/js-packages/connection/changelog/fix-recommendations-connect-after-checkout b/projects/js-packages/connection/changelog/fix-recommendations-connect-after-checkout new file mode 100644 index 0000000000000..11cf7a8b03bcb --- /dev/null +++ b/projects/js-packages/connection/changelog/fix-recommendations-connect-after-checkout @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Fetch adminUrl current value on function run diff --git a/projects/js-packages/connection/hooks/use-product-checkout-workflow/index.jsx b/projects/js-packages/connection/hooks/use-product-checkout-workflow/index.jsx index 1462a9d9584d2..6fe043288e439 100644 --- a/projects/js-packages/connection/hooks/use-product-checkout-workflow/index.jsx +++ b/projects/js-packages/connection/hooks/use-product-checkout-workflow/index.jsx @@ -15,7 +15,7 @@ const { apiNonce, siteSuffix: defaultSiteSuffix, } = window?.JP_CONNECTION_INITIAL_STATE || getScriptData()?.connection || {}; -const defaultAdminUrl = +const defaultAdminUrl = () => typeof window !== 'undefined' ? window?.myJetpackInitialState?.adminUrl : null; /** @@ -38,7 +38,7 @@ export default function useProductCheckoutWorkflow( { productSlug, redirectUrl, siteSuffix = defaultSiteSuffix, - adminUrl = defaultAdminUrl, + adminUrl = defaultAdminUrl(), connectAfterCheckout = false, siteProductAvailabilityHandler = null, quantity = null, diff --git a/projects/packages/my-jetpack/changelog/fix-recommendations-connect-after-checkout b/projects/packages/my-jetpack/changelog/fix-recommendations-connect-after-checkout new file mode 100644 index 0000000000000..34ef82e79b08f --- /dev/null +++ b/projects/packages/my-jetpack/changelog/fix-recommendations-connect-after-checkout @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Fix parameters to allow for connectAfterCheckout flow from recommendation card