For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
I am using the checkout extensibility function and am trying to update the total tax amount based on the customer name and shipping address (this is for tax exempt purposes) but I am running into some trouble and am not sure what's wrong. I am getting an error message
[ { "path": [ "errors" ], "explanation": "Expected value to not be null" }, { "path": [ "updatedTaxAmount" ], "explanation": "Field is not defined on FunctionRunResult" } ]
Here is how I set up my file (I am trying to modify the cart cost price no matter the condition for now just to see if it will work)
import type {CartCost, FunctionError, FunctionRunResult, RunInput,} from "../generated/api";
import {CurrencyCode} from "../generated/api";
export function run(input: RunInput): FunctionRunResult {
const currentBuyerAddress:string = input.cart.deliveryGroups[0]?.deliveryAddress?.address1 ?? '';
let errors: FunctionError[] = input.cart.lines
.filter(({ quantity }) => quantity > 1)
.map(() => ({
localizedMessage: "Not possible to order more than one of each",
target: "cart",
}));
const updatedTaxAmount: CartCost = {
subtotalAmount: {
amount: "749.00",
currencyCode: CurrencyCode.Usd
},
totalAmount:{
amount: "749.00",
currencyCode: CurrencyCode.Usd
},
totalTaxAmount: {
amount: "0.00",
currencyCode: CurrencyCode.Usd
}
};
return {
errors,
updatedTaxAmount
}
};
and here is what i added in my schema
type FunctionRunResult {
errors: [FunctionError!]!
updatedTaxAmount: CartCostInput!
}
"""
The result of a cart validation function.
"""
input FunctionRunResult {
"""
Errors.
"""
errors: [FunctionError!]!
"""
Updated Tax Amount.
"""
updatedTaxAmount: CartCostInput!
}
input CartCostInput {
subtotalAmount: MoneyV2Input!
totalAmount: MoneyV2Input!
totalTaxAmount: MoneyV2Input
}
input MoneyV2Input {
amount: String!
currencyCode: String!
}