return

Returns a value from a function or sends a response from HTTP, shipping-rate and function scripts. Stops script execution immediately after returning.

{% json response %}
  {
    "success": true,
    "message": "Operation completed"
  }
{% endjson %}

{% return response %}

Syntax

{% return value %}

Parameters

Parameter
Required
Description

value

Yes

The value to return (variable, object, string, number, etc.)

Behavior

  • Immediately stops script execution

  • Sets the return value accessible to the caller

  • In functions: the returned value is output where the function was called

  • In HTTP scripts: the returned value becomes the response body

  • In shipping-rate scripts: the returned value defines the shipping rates

  • Only one value can be returned

Examples

Return from a function:

Return an object from a function:

Return simple values:

HTTP script response:

Shipping rates response:

Early return with validation:

Conditional return based on logic:

Return array data:

Return with computed values:

Use Cases

Context
Purpose

Functions

Return computed values to the calling script

HTTP Scripts

Send response body to the HTTP caller

Shipping Rate Scripts

Define available shipping rates and prices

Notes

  • Only one argument is allowed - you cannot return multiple values directly

  • To return multiple values, wrap them in an object using the json tag

  • Script execution stops immediately after return - code after it won't run

  • If no return is called in a function, the function returns null

  • For complex responses, always use json tag to structure the data

  • The returned value from functions is a string - use | parse_json if you need to access object properties in the caller

Last updated