updateDiscountRule( )
Updates a discount rule's properties.
Description
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.
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function updateDiscountRule(_id: string, discountRule: UpdateDiscountRule): Promise<DiscountRule>
updateDiscountRule Parameters
NAME
TYPE
DESCRIPTION
Discount rule ID.
Discount rule info.
Returns
Updated discount rule.
Return Type:
NAME
TYPE
DESCRIPTION
Date and time the discount rule was created.
Discount rule ID.
Date and time the discount rule was last updated.
Whether the discount rule is active.
Default: true
Time frame in which the discount rule is active.
List of discounts that are applied when one or more triggers are met.
Currently, a discount rule can apply only 1 discount.
Discount rule name.
Revision number, which increments by 1 each time the discount rule is updated.
To prevent conflicting changes, the current revision
must be passed when updating the discount rule.
Discount rule status.
Discount rule trigger.
A set of conditions that must be met for the discounts
to be applied.
Not passing a trigger will cause the discount to always apply.
Number of times the discount rule was used.
Was this helpful?
updateDiscountRule example
1import { discountRules } from 'wix-ecom-backend';23 async function updateDiscountRule(id, discountRule, options) {4 try {5 const result = await discountRules.updateDiscountRule(id, discountRule, options);67 return result;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12 }13