Discount codes
A discount is a price incentive offered to customers to promote a purchase. A discount code is a calculation code whose calculation usage is "discount." It is used to calculate order item adjustments. Each row in the CALCODE table represents a CalculationCode. CalculationCodes represent ways of determining monetary amounts associated with OrderItems. They are used to calculate discounts, shipping charges, sales tax, and shipping tax. A CalculationCode attachment can be limited to specific TradingAgreements.
Two dimensions are involved in attaching a discount code to a product or a group of products. First, the discount can be attached to one or more catalog entries, and catalog groups. Attaching a calculation code to a catalog group has the same effect as attaching it to all the catalog entries directly in the catalog group.
Second, the order items are grouped for calculation in one of four ways: per trading agreement, per product, per offer, or per shipping address. This is specified by the groupBy attribute. A separate calculation is performed for each group of OrderItem objects. If no grouping is specified, then all the OrderItems attached to a particular CalculationCode object are used to perform a single calculation. The following outlines the attributes used to calculate different types of discounts:
- Discounts calculated by trading agreement
- The perTradingAgreement attribute means that all order items in a group must have the same trading agreement for the calculation code to be applied.
- Discounts calculated by product
- The perProduct attribute means that all order items in a group must be associated with the same product for the calculation code to be applied. (The product can be either the catalog item's parent catalog entry, according to the PRODUCT_ITEM relationship type in the CATRELTYPE database table (if there is one), or just the catalog item itself.)
- Discounts calculated by offer
- The perOffer attribute grouping is appropriate for tax calculation codes.
- Discounts calculated by shipping address
- Although normally used for calculating shipping charges, the perShippingAddress groupBy attribute can also be used to group order items for discount codes according to their shipping addresses.
Products can have more than one discount associated with them. Similarly, member groups can be eligible for more than one discount. When more than one discount calculation code applies to an Order object, discount calculations are performed in ascending sequence of their CalculationCode object sequence attributes. This restricts a calculation code for use only by certain member groups as defined in the CALCODEMGP table. As with all calculation codes, multiple discount codes can be associated with each product and discount codes can be restricted for use only by certain member groups.