About Custom Discount Triggers SPI

The eCommerce Custom Discount Triggers 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 Developers Center) and the Wix Custom Discount Triggers SPI.

Learn more about implementing an SPI with Wix.

Before you begin

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.

Use cases

Configuration

Complete the following steps to adapt Wix system's integration to make your custom triggers available to merchants and their customers.

  1. Go to the Extensions tab in the Wix Developers Center.

  2. Click Create Extension in the top right.

  3. Filter by eCommerce in the left menu, then find Ecom Discounts Trigger and click Create.

  4. Provide the following configuration:

    NameTypeDescription
    deploymentUristringRequired. 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/.
    componentNamestringA unique name for this component. This is an internal name that will only appear in the Dev Center.
Was this helpful?
Yes
No

Sample Flows

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.

Offer a happy hour discount

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:

  1. Configure your app with custom triggers that are retrieved by Wix when List Triggers is called. For example, give a custom trigger these properties:
  • "id": "happy-hour-trigger"
  • "name": "Happy Hour, weekdays, 16:00-18:00"
  1. 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.

  2. 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.

Offer a sale on digital products

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:

  1. Configure your app with custom triggers that are retrieved by Wix when List Triggers is called. For example, give a custom trigger these properties:
  • "id": "digital-sale-trigger"
  • "name": "Digital products discount"
  1. 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.

  2. 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.

Was this helpful?
Yes
No

PostList Triggers

Developer Preview

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 SPI integration.

This function is automatically called by Wix eCommerce to populate the custom minimum requirements section of an automatic discount.

You cannot try out this endpoint because it has to be implemented by an app and can have an arbitrary URL. Therefore, ignore the Authorization and POST sections below as well as the Try It Out button.

Endpoint
POST
{DEPLOYMENT-URI}/v1/list-triggers
Was this helpful?
Yes
No

PostGet Eligible Triggers

Developer Preview

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 function 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.

You cannot try out this endpoint because it has to be implemented by an app and can have an arbitrary URL. Therefore, ignore the Authorization and POST sections below as well as the Try It Out button.

Endpoint
POST
{DEPLOYMENT-URI}/v1/get-eligible-triggers
Was this helpful?
Yes
No