For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
Hi,
I have an extension for blocking the checkout process when trying to continue without entering an house number. But I am getting this error when activating the rule. Is there a mistake in the code?
This is the run.js:
/** * @typedef {import("../generated/api").RunInput} RunInput * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult */ /** * @param {RunInput} input * @returns {FunctionRunResult} */ export function run(input) { const errors = []; if(input.buyerJourney.step != "CART_INTERACTION") { // the error const errorHousnumber = { localizedMessage: "Füge bitte eine Hausnummer hinzu.", target: "cart.deliveryGroups[0].deliveryAddress?.address1" } const customerAdressOne = input.cart.deliveryGroups[0].deliveryAddress?.address1; const customerAdressTwo = input.cart.deliveryGroups[0].deliveryAddress?.address2; const containsHouseNumberOne = /\d/.test(customerAdressOne); // address housenumber validation if (!containsHouseNumberOne) { errors.push(errorHousnumber); } } return { errors } };
And this is the run.graphql:
query RunInput { buyerJourney{ step } cart { deliveryGroups { deliveryAddress { address1 address2 company firstName lastName } } } }
This is the error message i am getting:
Thank you in advance!
Best regards,
Yodit