What’s happens
When you call any update api such as useApplyAttributeChange
, useApplyShippingAddressChange
and useApplyCartLinesChange
in useBuyerJourneyIntercept, it case infinity loop.
const applyAttributeChange = useApplyAttributeChange();
useBuyerJourneyIntercept(
({canBlockProgress}) => {
return canBlockProgress && address?.countryCode && address.countryCode !== 'CA'
? {
behavior: 'block',
reason: 'Invalid shipping country',
errors: [
{
message:
'Sorry, we can only ship to Canada',
// Show an error underneath the country code field
target:
'$.cart.deliveryGroups[0].deliveryAddress.countryCode',
},
{
// In addition, show an error at the page level
message:
'Please use a different address.',
},
],
}
: {
behavior: 'allow',
perform: async () => {
await applyAttributeChange({....});
};
};
},
);