How To Initiate A Redirect From A Shopify Checkout Validation App

How To Initiate A Redirect From A Shopify Checkout Validation App

New Member
4 0 1

Hello, I have followed the below tutorial and created a Shopify checkout validation app.


Everything is working as expected, however, if the validation fails, instead of showing a message, I would like to redirect the customer to the cart page.


How would I go about acheiving this,


Please see simplified version of my code below:



// @ts-check
// Use JSDoc annotations for type safety
 * @typedef {import("../generated/api").InputQuery} InputQuery
 * @typedef {import("../generated/api").FunctionResult} FunctionResult
// The @shopify/shopify_function package will use the default export as your function entrypoint
export default
 * @param {InputQuery} input
 * @returns {FunctionResult}

(input) => {

    // The error
    const error = {
            "This is a example message",
        target: "cart"

    const errors = [];

   if (true) {
     // TODO: Redirect customer to cart page
} return {errors}; };

The error is showing as expected, but I would instead like to initiate a redirect.


I have been at this for hours with no success. Any help would be greatly appreciated.

Reply 1 (1)

Shopify Staff
1451 238 497

Hi @SoapMatt,


While we don't currently provide direct support for Functions in this forum, the public [Shopify/function-examples GitHub repository] has an active [discussion board] that might be worth checking out.
Hope you have a great day

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit or the Shopify Web Design and Development Blog