The eCommerce Custom Discount Triggers service plugin (formerly SPI) allows you to provide custom triggers that specify when a discount can apply to a cart and checkout.
Custom triggers play a part in the definition of discount rules - sets of triggers and scopes that together define the necessary conditions for a discount to apply to items in the cart and checkout. For example, a trigger that only fires between 4pm-6pm on Mondays through Thursdays.
The integration is done via an app in the Wix App Market (created in the Wix Studio workspace), and the Wix Custom Discount Triggers service plugin.
Learn more about service plugin extensions.
To use a custom trigger to apply a discount, you must first create a discount rule. Create an automatic discount using the dashboard, or by using the Discount Rules API.
Complete the following steps to adapt Wix system's integration to make your custom triggers available to merchants and their customers.
Go to Extensions in your app's dashboard.
Click Create Extension in the top right.
Filter by eCommerce in the left menu, then find Ecom Discounts Trigger and click Create.
Provide the following configuration:
Name | Type | Description |
---|---|---|
deploymentUri | string | Required. Base URI where the endpoints are called. Wix appends the endpoint path to the base URI. For example, to call the Get Eligible Triggers endpoint at https://my-discount-app.com/v1/getEligibleTriggers , the base URI you provide here is https://my-discount-app.com/ . |
componentName | string | A unique name for this component. This is an internal name that will only appear in the app dashboard. |
This article presents sample flows your app can support. You aren't limited to these exact flows, but they can be a helpful jumping off point as you plan your Custom Discount Triggers integration.
Your app can allow sites to offer customers a happy hour discount. With a custom trigger based on the time an order is placed, an automatic discount can be applied.
To create a custom trigger for a happy hour discount:
"id"
: "happy-hour-trigger"
"name"
: "Happy Hour, weekdays, 16:00-18:00"
Create a discount rule that includes the amount of the discount to apply, which items to apply the discount to, and which custom trigger to use to trigger the rule.
Wix calls Get Eligible Triggers when actions are taken on the cart or checkout entities/pages. Your app should determine if the time of the customer's action should trigger the Happy Hour discount rule to apply. If so, the customer will see the discounted price.
Your app can allow sites to offer discounts on certain types of products, such as, digital products.
To create a custom trigger for a digital discount:
"id"
: "digital-sale-trigger"
"name"
: "Digital products discount"
Create a discount rule that includes the amount of the discount to apply, which category of items to apply the discount to, and which custom trigger to use to trigger the rule.
Wix calls Get Eligible Triggers when actions are taken on the cart or checkout entities/pages. Use Get Product to check the productType
and determine if the product a customer views triggers the digital discount rule to apply. If so, the customer will see the discounted price.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Lists all custom triggers provided by your service plugin integration.
This method is automatically called by Wix eCommerce to populate the custom minimum requirements section of an automatic discount.
Custom triggers.
The data payload will include the following object as an encoded JWT. For the purposes of this example, we show the request and response objects decoded.
curl -X POST https://provider.example.com/v1/listTriggers \
-H 'user-agent: Wix' \
-H 'accept-encoding: gzip, deflate' \
-H 'content-type: text/plain; charset=utf-8'
{
"customTriggers": [
{
"id": "my-happy-hour-trigger",
"name": "Happy Hour 16:00-18:00"
},
{
"id": "my-digital-sale-trigger",
"name": "Digital products discount"
}
]
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves eligible custom discount triggers based on the provided items.
This method is automatically called by Wix eCommerce to retrieve the custom discount triggers provided by your extension. This happens when actions are performed on the cart and checkout entities/pages. For example, when an item is added to the cart.
List of line items in the cart/checkout.
List of triggers to be checked for discount eligibility.
Persistent ID that correlates between the various eCommerce elements: cart, checkout, and order.
List of eligible triggers. These are used by the Discount Rules API and Wix eCommerce to apply the relevant discount.
The data payload will include the following object as an encoded JWT. For the purposes of this example, we show the request and response objects decoded.
curl -X POST https://provider.example.com/v1/getEligibleTriggers \
-H 'user-agent: Wix' \
-H 'accept-encoding: gzip, deflate' \
-H 'content-type: text/plain; charset=utf-8'
--data-binary '{
"triggers": [
{
"customTrigger": {
"id": "my-happy-hour-trigger"
},
"identifier": "123"
},
{
"customTrigger": {
"id": "my-digital-sale-trigger"
},
"identifier": "234"
}
],
"lineItems": [
{
"catalogReference": {
"appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e",
"catalogItemId": "b8b60eb2-f0c0-2519-c884-4e45ba25f0f7"
},
"id": "00000000-0000-0000-0000-000000000001",
"price": "250.00",
"quantity": {
"value": 1
}
},
{
"catalogReference": {
"appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e",
"catalogItemId": "c11f4db2-50cd-f4ea-d278-18c0914215d9",
},
"id": "00000000-0000-0000-0000-000000000002",
"price": "215.00",
"quantity": {
"value": 1
}
}
]
}
{
"eligibleTriggers": [
{
"customTriggerId": "my-happy-hour-trigger",
"identifier": "123"
},
{
"customTriggerId": "my-digital-sale-trigger",
"identifier": "234"
}
]
}