int
CSaleDiscount::Add(
array arFields
);
The method Add adds a new discount.
Parameters
Parameter | Description |
arFields |
Associated array whose keys are the discount parameter names, and the
values are the parameter values.
The following keys are possible:
- LID - the ID of the site to which this discount is bound;
- PRICE_FROM - minimum total order price to which this discount is applicable;
- PRICE_TO - maximum total order price to which this discount is applicable;
- CURRENCY - currency in which all money values are specified in this record;
- DISCOUNT_VALUE - discount value;
- DISCOUNT_TYPE - type of the discount value (P - percentage, V - absolute
value);
- ACTIVE - flag indicating the discount is active (Y/N);
- SORT - sort weight. If more than one discount can be applied to an order price,
the discount with the less SORT is taken first.
- LAST_DISCOUNT - флаг "Don't apply discounts". When applied and flag is checked, all subsequent discounts won't be used (regardless of their conditions are matching or not);
- LAST_LEVEL_DISCOUNT - flag "Disable priority level". Similar to the previous flag, but cancels only the subsequent rules with the same priority;
- XML_ID - external ID;
- CONDITIONS - array, describing additional rule conditions;
- ACTIONS - array, describing rule actions;
- USER_GROUPS - array with user groups with the rule applied (cannot be empty);
- CURRENCY - starting from version 14.0 forcibly contains site currency;
- PRICE_FROM - total order price, starting when such discount is granted the price with such discount granted. Deprecated field, starting from version 14.0, value is forcibly re-defined when adding;
- PRICE_TO - total order price, when reached, assigns this discount. Deprecated field, starting from version 14.0, value is forcibly re-defined when adding;
- DISCOUNT_VALUE - discount amount. Deprecated field, starting from version 14.0, value is forcibly re-defined when adding;
- DISCOUNT_TYPE - type of discount amount (P - value is defined in percents, V - value is defined in gross value). Deprecated field, starting from version 14.0, value is forcibly re-defined when adding;
Coupon block:
-
COUPON_ADD - create coupons of a single type when adding rule or not (Y/N);
- COUPON_COUNT - number of created coupons;
- COUPON - array, describing the coupon:
- TYPE - coupon type (Y - coupon for a single order position, O - coupon for a single order, N - multiple use coupon);
- ACTIVE_FROM - date and time of coupon validity start in site's format or null;
- ACTIVE_TO - date and time of coupon validity expiration in site's format or null;
- MAX_USE - maximum number of coupon uses (for multiple-use coupon) or 0.
|
Returned values
Returns the ID of the new discount or false otherwise.