Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Updating cart attributes inside useBuyerJourneyIntercept doesn't work

Updating cart attributes inside useBuyerJourneyIntercept doesn't work

JH12
Shopify Partner
3 0 2

Hello everyone!

 

I'd like to update cart attributes when user clicks the "complete order" button.
So I call the useApplyAttributeChange func (https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/react-hooks/attributes/useapplyattribute...) inside the useBuyerJourneyIntercept.
I think it processes the payment and redirect to the thank you page after receiving the result from the updateAttribute, but it doesn't work out as I expected and still remains in the payment page. 
I want to know the reason. Could anyone explain it to me please?


const updateAttribute = useApplyAttributeChange();
const isRunning = useRef<boolean>(false);

useBuyerJourneyIntercept(async ({ canBlockProgress }) => { if (isRunning.current && canBlockProgress) { return { behavior: "block", reason: "Enter your password", }; } isRunning.current = true; const result = await updateAttribute({ type: "updateAttribute", key: "key", value: "value", }); isRunning.current = false;
return { behavior: "allow", }; });

 

 

Replies 0 (0)