Setup
To use the DiscountRules API, install the @wix/ecom
package using npm or Yarn:
1npm install @wix/ecom
or
1yarn add @wix/ecom
Then import { discountRules }
from @wix/ecom
:
1import { discountRules } from '@wix/ecom'
Creates a new discount rule.
The createDiscountRule()
function returns a Promise that resolves to the new discount rule when it's created.
Permission Scopes
For app development, you must have one of the following permission scopes:function createDiscountRule(discountRule: DiscountRule): Promise<DiscountRule>
Discount rule info.
Deletes a discount rule.
The deleteDiscountRule()
function returns a Promise that resolves when the specified discount rule is deleted.
Permission Scopes
For app development, you must have one of the following permission scopes:function deleteDiscountRule(discountRuleId: string): Promise<void>
ID of the discount rule to delete.
Retrieves a discount rule.
The getDiscountRule()
function returns a Promise that resolves when the specified discount rule is retrieved.
Permission Scopes
For app development, you must have one of the following permission scopes:function getDiscountRule(discountRuleId: string): Promise<DiscountRule>
ID of the discount rule to retrieve.
Creates a query to retrieve a list of discount rules.
The queryDiscountRules() function builds a query to retrieve a list of up to 100 discount rules, and returns a DiscountRulesQueryBuilder
object.
The returned object contains the query definition which is typically used to run the query using the find()
function.
You can refine the query by chaining DiscountRulesQueryBuilder
functions onto the query. DiscountRulesQueryBuilder
functions enable you to sort, filter, and control the results queryDiscountRules() returns.
By default, queryDiscountRules()
sorts results by ascending("_id")
by default. This can be overridden.
To learn how to query posts, refer to the table below.
The following DiscountRulesQueryBuilder
functions are supported for the queryDiscountRules()
function. For a full description of the discount rule object, see the object returned for the items
property in DiscountRulesQueryResult
.
PROPERTY | SUPPORTED FILTERS & SORTING |
---|---|
_id | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() ,ascending() ,descending() |
revision | eq() ,ne() ,exists() ,in() ,hasSome() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
_createdDate | eq() ,ne() ,exists() ,in() ,hasSome() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
_updatedDate | eq() ,ne() ,exists() ,in() ,hasSome() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
active | eq() ,ne() ,exists() ,in() ,hasSome() ,ascending() ,descending() |
name | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() ,ascending() ,descending() |
activeTimeInfo.start | eq() ,ne() ,exists() ,in() ,hasSome() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
activeTimeInfo.end | eq() ,ne() ,exists() ,in() ,hasSome() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
Permission Scopes
For app development, you must have one of the following permission scopes:function queryDiscountRules(): DiscountRulesQueryBuilder
Updates a discount rule's properties.
The updateDiscountRule()
function returns a Promise that resolves when the specified discount rule's properties are updated.
Each time the discount rule is updated, revision
increments by 1. The existing revision
must be included when updating the discount rule. This ensures you're working with the latest discount rule information, and it prevents unintended overwrites.
Permission Scopes
For app development, you must have one of the following permission scopes:function updateDiscountRule(_id: string, discountRule: UpdateDiscountRule): Promise<DiscountRule>
Discount rule ID.
Discount rule info.