post https://{shopdomain}.myshoplaza.com/openapi/2024-07/function/cart-transform
Requires
write_cart_transform
access scope.
The Cart-Transform Function API allows developers to bind a previously uploaded Function to the cart price adjustment process in Shoplazza. Once bound, Shoplazza will automatically execute the function during cart and checkout stages to dynamically modify product prices.
- Automatically applies the function logic to cart and checkout pricing.
- Only one function can be bound to the cart price adjustment at a time.
- Supports failure handling options (block_on_failure).
Request Parameters
Public Request Parameters
Body Parameters
Parameter | Type | Required | Description |
---|---|---|---|
function_id | string | Yes | The function_id returned from the Function API after uploading, which specifies the price adjustment logic. |
block_on_failure | bool | No | Determines whether to block the cart/checkout process if the Function execution fails. Default false |
input_query | raw json string | No | A JSON string specifying metafield queries for cart line items. |
input query structure
Parameter | Type | Required | Description |
---|---|---|---|
product_metafields_query | array | No | Defines rules to query Metafield data. If empty, the function input will not contain Metafield data. The array length is limited to 1, currently supporting only one key. |
namespace | string | Yes | The namespace of the Metafield. |
key | string | Yes | The key of the Metafield. |
Example input_query
JSON:
input_query
JSON:"{\"product_metafields_query\": [{\"namespace\": \"custom-option\", \"key\": \"adjust-10-price\"}]}"
Response Explanation
Public Response Parameters
Successful Response
Parameter | Type | Required | Description |
---|---|---|---|
code | string | Yes | Response status code, "SUCCESS" if successful |
message | string | Yes | Response message, "SUCCESS" if successful |
data | object | Yes | Contains response data |
data.id | string | Yes | Unique cart-transform-function ID |
data.block_on_failure | bool | Yes | Indicates whether failure should block checkout (false by default) |
Error Response
Field | Type | Description | Example |
---|---|---|---|
code | string | The error code indicating the type of issue. | InvalidParameter |
message | string | A detailed message describing the error. | wrong cursor |