From 96e0af8a10ccdc80e502286e62fa38e01d67a8ad Mon Sep 17 00:00:00 2001 From: Matthew Kim Date: Wed, 25 Oct 2023 15:28:23 -0400 Subject: [PATCH] fix useSales init script --- blocks/subscriptions-block/components/useSales.jsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/blocks/subscriptions-block/components/useSales.jsx b/blocks/subscriptions-block/components/useSales.jsx index 7d33fe3741..c0c2a29aed 100644 --- a/blocks/subscriptions-block/components/useSales.jsx +++ b/blocks/subscriptions-block/components/useSales.jsx @@ -7,13 +7,19 @@ import getProperties from "fusion:properties"; const useSales = () => { const { arcSite } = useFusionContext(); const { api } = getProperties(arcSite); - const [isInit, setIsInit] = useState(!!Identity.apiOrigin); + const [isInit, setIsInit] = useState(!!Sales.apiOrigin); + const isIdentityInit = !!Identity.apiOrigin; - if (!isInit && arcSite && api?.identity?.origin) { - Identity.options({ apiOrigin: api.identity.origin }); + const identityApiOrigin = api?.identity?.origin ?? api?.sales?.origin ?? api?.retail?.origin; + const salesApiOrigin = api?.sales?.origin ?? api?.identity?.origin ?? api?.retail?.origin; + if (!isIdentityInit && arcSite && identityApiOrigin) { + Identity.options({ apiOrigin: identityApiOrigin }); + } + + if (!isInit && arcSite && salesApiOrigin) { Sales.options({ - apiOrigin: api?.retail?.origin, + apiOrigin: salesApiOrigin, Identity, });