Setup

To use the DiscountRules API, install the @wix/ecom package using npm or Yarn:

Copy
1
npm install @wix/ecom

or

Copy
1
yarn add @wix/ecom

Then import { discountRules } from @wix/ecom:

Copy
1
import { discountRules } from '@wix/ecom'
Was this helpful?
Yes
No

createDiscountRule( )

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:
Manage Stores - all permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function createDiscountRule(discountRule: DiscountRule): Promise<DiscountRule>
Method Parameters
discountRuleDiscountRuleRequired
Discount rule info.
Returns
Return Type:Promise<DiscountRule>
Was this helpful?
Yes
No

deleteDiscountRule( )

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:
Manage Stores - all permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function deleteDiscountRule(discountRuleId: string): Promise<void>
Method Parameters
discountRuleIdstringRequired
ID of the discount rule to delete.
Returns
Return Type:Promise<void>
Was this helpful?
Yes
No

getDiscountRule( )

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:
Manage Stores - all permissions
Read eCommerce - all read permissions
Read Stores - all read permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function getDiscountRule(discountRuleId: string): Promise<DiscountRule>
Method Parameters
discountRuleIdstringRequired
ID of the discount rule to retrieve.
Returns
Return Type:Promise<DiscountRule>
Was this helpful?
Yes
No

queryDiscountRules( )

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.

PROPERTYSUPPORTED FILTERS & SORTING
_ideq(),ne(),exists(),in(),hasSome(),startsWith(),ascending(),descending()
revisioneq(),ne(),exists(),in(),hasSome(),lt(),le(),gt(),ge(),ascending(),descending()
_createdDateeq(),ne(),exists(),in(),hasSome(),lt(),le(),gt(),ge(),ascending(),descending()
_updatedDateeq(),ne(),exists(),in(),hasSome(),lt(),le(),gt(),ge(),ascending(),descending()
activeeq(),ne(),exists(),in(),hasSome(),ascending(),descending()
nameeq(),ne(),exists(),in(),hasSome(),startsWith(),ascending(),descending()
activeTimeInfo.starteq(),ne(),exists(),in(),hasSome(),lt(),le(),gt(),ge(),ascending(),descending()
activeTimeInfo.endeq(),ne(),exists(),in(),hasSome(),lt(),le(),gt(),ge(),ascending(),descending()

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Stores - all permissions
Read eCommerce - all read permissions
Read Stores - all read permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function queryDiscountRules(): DiscountRulesQueryBuilder
Request
This method does not take any parameters
Returns
Was this helpful?
Yes
No

updateDiscountRule( )

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:
Manage Stores - all permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function updateDiscountRule(_id: string, discountRule: UpdateDiscountRule): Promise<DiscountRule>
Method Parameters
_idstringRequired
Discount rule ID.

discountRuleUpdateDiscountRuleRequired
Discount rule info.
Returns
Return Type:Promise<DiscountRule>
Was this helpful?
Yes
No