> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GetEligibleTriggers

# Package: discounts

# Namespace: CustomTriggersProvider

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/discounts/custom-discount-triggers-integration-service-plugin/get-eligible-triggers.md

## Introduction

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.

---

## REST API

### Schema

```
 Method: getEligibleTriggers
 Description: 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.
 URL: {DEPLOYMENT-URI}/v1/get-eligible-triggers
 Method: POST
 Method parameters:
   param name: lineItems | type: array<lineItems> | description: List of line items in the cart/checkout.  | validation: maxItems 1000
              - name: id | type: string | description: Line item GUID.  | validation: minLength 1, maxLength 100
              - name: quantity | type: integer | description: Item quantity in this line item.  | validation: minimum 0, maximum 100000, format int32
              - name: catalogReference | type: CatalogReference | description: Catalog and item reference. Holds GUIDs for the item and the catalog it came from, as well as further optional info. This field may be empty in the case of a custom line item.  
                 - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to.  | validation: minLength 1, maxLength 36
                 - name: appId | type: string | description: GUID of the app providing the catalog.  You can get your app's GUID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/).  For items from Wix catalogs, the following values always apply: + Wix Stores: `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` + Wix Bookings: `"13d21c63-b5ec-5912-8397-c3a5ddb27a97"` + Wix Restaurants: `"9a5d83fd-8570-482e-81ab-cfa88942ee60"`  | validation: minLength 1
                 - name: options | type: object | description: Additional item details in `key:value` pairs.  Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items.  For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration.md) or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration.md), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction.md).  
              - name: price | type: string | description: Price of a single item.  | validation: decimalValue {"gte":"0"}
   param name: purchaseFlowId | type: purchaseFlowId | description: Persistent GUID that correlates between the various eCommerce elements: cart, checkout, and order.  | validation: format GUID
   param name: shippingInfo | type: ShippingInfo    
        - name: address | type: Address | description: Address (if applicable).  
           - name: country | type: string | description: Two-letter country code in [ISO-3166 alpha-2](https://www.iso.org/obp/ui/#search/code/) format.  | validation: format COUNTRY
           - name: subdivision | type: string | description: Code for a subdivision (such as state, prefecture, or province) in [ISO 3166-2](https://www.iso.org/standard/72483.html) format.  | validation: maxLength 50
           - name: city | type: string | description: City name.  | validation: maxLength 50
        - name: preferredShippingOptionCode | type: string | description: Preferred shipping option code. For example, "usps_std_overnight".  | validation: minLength 1, maxLength 100
   param name: sitePaymentMethodTypeId | type: sitePaymentMethodTypeId | description: GUID of the site payment method type the buyer selected to pay with. Learn more about the [Site Payment Method Types API](https://dev.wix.com/docs/api-reference/business-management/payments/site-payment-method-types/introduction.md).  Available only when the buyer selects a payment method during the purchase flow.  | validation: format GUID
   param name: triggers | type: array<triggers> | description: List of triggers to be checked for discount eligibility.  | validation: minItems 1, maxItems 1000
              - name: customTrigger | type: CustomTrigger | description: Custom trigger info.  
                 - name: id | type: string | description: Custom trigger GUID.  | validation: minLength 1, maxLength 100
              - name: identifier | type: string | description: Unique trigger identifier. The same value must be returned in `eligibleTriggers[i].identifier`.  | validation: minLength 1, maxLength 120
 Return type: GetEligibleTriggersResponse
  - name: eligibleTriggers | type: array<EligibleTrigger> | description: List of eligible triggers. These are used by the Discount Rules API and Wix eCommerce to apply the relevant discount.  | validation: minItems 0, maxItems 1000
     - name: customTriggerId | type: string | description: Custom trigger GUID. Must be passed with relevant `identifier`.  | validation: minLength 1, maxLength 100
     - name: identifier | type: string | description: Unique trigger identifier. The value must be the same as its equivalent in `triggers[i].identifier` in the request payload.  | validation: minLength 1, maxLength 120


```

### Examples

### Get eligible custom triggers - decoded JWT
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
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": 1
     },
     {
      "catalogReference": {
       "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e",
       "catalogItemId": "c11f4db2-50cd-f4ea-d278-18c0914215d9"
      },
      "id": "00000000-0000-0000-0000-000000000002",
      "price": "215.00",
      "quantity": 1
     }
    ]
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.customTriggers.getEligibleTriggers(request, metadata)
 Description: 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.
 Method parameters:
   param name: request | type: GetEligibleTriggersRequest    
        - name: lineItems | type: array<LineItem> | description: List of line items in the cart/checkout.  | validation: maxItems 1000
           - name: _id | type: string | description: Line item GUID.  | validation: minLength 1, maxLength 100
           - name: quantity | type: integer | description: Item quantity in this line item.  | validation: minimum 0, maximum 100000, format int32
           - name: catalogReference | type: CatalogReference | description: Catalog and item reference. Holds GUIDs for the item and the catalog it came from, as well as further optional info. This field may be empty in the case of a custom line item.  
              - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to.  | validation: minLength 1, maxLength 36
              - name: appId | type: string | description: GUID of the app providing the catalog.  You can get your app's GUID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/).  For items from Wix catalogs, the following values always apply: + Wix Stores: `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` + Wix Bookings: `"13d21c63-b5ec-5912-8397-c3a5ddb27a97"` + Wix Restaurants: `"9a5d83fd-8570-482e-81ab-cfa88942ee60"`  | validation: minLength 1
              - name: options | type: object | description: Additional item details in `key:value` pairs.  Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items.  For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration.md) or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration.md), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction.md).  
           - name: price | type: string | description: Price of a single item.  | validation: decimalValue {"gte":"0"}
        - name: triggers | type: array<TriggerToFilterBy> | description: List of triggers to be checked for discount eligibility.  | validation: minItems 1, maxItems 1000
           - name: customTrigger | type: CustomTrigger | description: Custom trigger info.  
              - name: _id | type: string | description: Custom trigger GUID.  | validation: minLength 1, maxLength 100
           - name: identifier | type: string | description: Unique trigger identifier. The same value must be returned in `eligibleTriggers[i].identifier`.  | validation: minLength 1, maxLength 120
        - name: purchaseFlowId | type: string | description: Persistent GUID that correlates between the various eCommerce elements: cart, checkout, and order.  | validation: format GUID
        - name: shippingInfo | type: ShippingInfo | description: Shipping information.  
           - name: address | type: Address | description: Address (if applicable).  
              - name: country | type: string | description: Two-letter country code in [ISO-3166 alpha-2](https://www.iso.org/obp/ui/#search/code/) format.  | validation: format COUNTRY
              - name: subdivision | type: string | description: Code for a subdivision (such as state, prefecture, or province) in [ISO 3166-2](https://www.iso.org/standard/72483.html) format.  | validation: maxLength 50
              - name: city | type: string | description: City name.  | validation: maxLength 50
           - name: preferredShippingOptionCode | type: string | description: Preferred shipping option code. For example, "usps_std_overnight".  | validation: minLength 1, maxLength 100
        - name: sitePaymentMethodTypeId | type: string | description: GUID of the site payment method type the buyer selected to pay with. Learn more about the [Site Payment Method Types API](https://dev.wix.com/docs/api-reference/business-management/payments/site-payment-method-types/introduction.md).  Available only when the buyer selects a payment method during the purchase flow.  | validation: format GUID
   param name: metadata | type: Context | description: this message is not directly used by any service, it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform. e.g. SPIs, event-handlers, etc.. NOTE: this context object MUST be provided as the last argument in each Velo method signature.  Example: ```typescript export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) { ... } ```  
        - name: requestId | type: string | description: A unique identifier of the request. You may print this GUID to your logs to help with future debugging and easier correlation with Wix's logs.  
        - name: currency | type: string | description: [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.  | validation: format CURRENCY
        - name: identity | type: IdentificationData | description: An object that describes the identity that triggered this request.  
           - ONE-OF: 
              - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site.  | validation: format GUID
              - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site.  | validation: format GUID
              - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.).  | validation: format GUID
              - name: appId | type: string | description: GUID of an app.  | validation: format GUID
        - name: languages | type: array<string> | description: A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`.  
        - name: instanceId | type: string | description: The service provider app's instance GUID.  | validation: format GUID
 Return type: PROMISE<GetEligibleTriggersResponse>
  - name: eligibleTriggers | type: array<EligibleTrigger> | description: List of eligible triggers. These are used by the Discount Rules API and Wix eCommerce to apply the relevant discount.  | validation: minItems 0, maxItems 1000
     - name: customTriggerId | type: string | description: Custom trigger GUID. Must be passed with relevant `identifier`.  | validation: minLength 1, maxLength 100
     - name: identifier | type: string | description: Unique trigger identifier. The value must be the same as its equivalent in `triggers[i].identifier` in the request payload.  | validation: minLength 1, maxLength 120


```

### Examples

### Example of an `eligibleTriggers` return value
```javascript
import { customTriggers } from '@wix/ecom/service-plugins';

customTriggers.provideHandlers({

  getEligibleTriggers: async ( payload ) => {
    const {request, metadata} = payload;
        // Use the `request` and `metadata` received from Wix and
        // apply custom logic.
      return {
        // Return your response exactly as documented to integrate with Wix.
        // Return value example:
        eligibleTriggers: [
          {
            customTriggerId: "my-happy-hour-trigger",
            identifier: "123"
          },
          {
            customTriggerId: "my-digital-sale-trigger",
            identifier: "234"
          }
        ]
      }
    }
});

```

### getEligibleTriggers (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { customTriggers } from '@wix/ecom/service-plugins';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { customTriggers },
  // Include the auth strategy and host as relevant
});


async function getEligibleTriggers(request,metadata) {
  const response = await myWixClient.customTriggers.getEligibleTriggers(request,metadata);
};
```

---