import {
reactExtension,
useBuyerJourneyIntercept,
} from '@shopify/ui-extensions-react/checkout';
export default reactExtension(
'purchase.checkout.block.render',
() => <Extension />,
);
function Extension() {
useBuyerJourneyIntercept(
({ canBlockProgress }) => {
let errors = [];
if(address.lastName?.length > 10){
errors.push({
message : '姓を10文字以内で入力してください',
target : '$.cart.deliveryGroups[0].deliveryAddress.lastName'
});
}
/* エラーがあればブロック */
if(canBlockProgress && errors.length){
return {
behavior : 'block',
reason : 'Invalid length',
errors : errors
};
}else{
return {
behavior : 'allow'
};
}
}
);
}