**TABLE OF CONTENTS**

- Introduction
- Types Of Discounts
- General Considerations
- Discount Distribution Workflow
- Steps Followed To Calculate And Distribute Discount Amounts For Line Item Total Or Sub Total
- Step 1 Check if any CSR discount was applied before
- Step 2 If the discount is a Line Item discount
- Step 3 If the discount is a CSR Discount or Order Discount
- Step 4 Distribute discount amounts
- Step 5 Calculate Maximum Applicable Discount (MAD)
- Step 6 Apply CSR Discount again
- Step 7 Calculate discount amounts for Order Summary

- Steps Followed To Calculate And Distribute Discount Amounts For Shipping

- Steps Followed To Calculate And Distribute Discount Amounts For Line Item Total Or Sub Total
- Example Of Discount Distribution Workflow

## Introduction

This article provides information about how the different types of discounts are applied and distributed among the line items from the Znode 9.7 release.

Note: This article does not provide information about the eligibility criteria for different discounts (i.e. promotions, coupons, and CSR discount) for Orders.

## Types Of Discounts

In Znode, discounts are categorized into the following:

Line item discounts

These discounts can be created and applied in the form of promotions or coupons over the line item Total (i.e. Unit Price * Quantity)

The following types of promotions/coupons come under line item discounts:-

Amount Off Product

Amount Off X If Y Is Purchased

Amount Off Brand

Amount Off Category

Amount Off Catalog

Percent Off Product

Percent Off Brand

Percent Off Category

Percent Off Catalog

Percent Off X If Y Is Purchased

Order discounts

These discounts can be created and applied in the form of promotions, or coupons, or CSR discounts over the Subtotal (i.e. sum of all line item Total)

The following types of promotions/coupons come under order discounts:-

Amount Off Order

Percent Off Order

Shipping discounts

These discounts can be created and applied in the form of promotions, or coupons over the Total Shipping (i.e. sum of all line item Shipping)

Note: No discounts are applied over Handling ChargesThe following types of promotions/coupons come under order discounts:-

Amount Off Shipping

Amount Off Shipping With Carrier

Percent Off Shipping

Percent Off Shipping With Carrier

## General Considerations

When any promotion/coupon based discount is applied,

Promotions get applied automatically first based on the display order i.e. promotion with the lowest display order is applied first and so on

Coupons can be applied manually after all promotions are automatically applied. The sequence in which coupons are applied is considered as the final sequence for calculating the discounts

Since CSR discount can be edited during/after order creation, therefore it is given the last priority. Therefore always promotions will be applied first, then coupons and then CSR discount

All types of discounts can be applied during order creation/management, except only Shipping promotions can be applied automatically when a Shipping Method or Shipping Address is changed for an Order. Other promotions cannot be applied while managing the order

- Before any discounts are applied, the application calculates and saves Maximum Applicable Discount (MAD) that indicates the maximum amount from the calculated discount value that can be applied to the line items or order or shipping. The initial value of MAD is the original total associated with line items, order, and shipping respectively.
- If while managing an order, admin user either changes the Shipping Type or Shipping Address-zipcode or line item Shipping amount then Shipping discount gets removed. In this scenario, Maximum Applicable Discount (MAD) for Shipping gets reset to its original value.
When an Order is being created the values of the following settings are taken into consideration for calculating the discount amounts:

Allow Promotions & Coupons Together

Promotions With Exceptions

Note: The same are not considered when a discount is applied while managing an Order

## Discount Distribution Workflow

### Steps Followed To Calculate And Distribute Discount Amounts For Line Item Total Or Sub Total

Whenever a new eligible discount (Line Item/Order Promotion or Coupon, or CSR Discount) is applied while creating an Order from the admin application or web store, or while managing an Order from admin application, the Znode application performs the below steps to decide the maximum discount amount that will be applied and distributed among the line items:

#### Step 1 Check if any CSR discount was applied before

Application checks if any CSR discount was applied before the new discount was applied. If CSR discount was applied, then follows Step 1.2 and the following steps, otherwise follows Step 1.4

Removes the complete CSR discount and the amounts distributed among the line items

Considers the last MAD for the line item total and subtotal

Moves towards either of the following steps:

Step 2 if the applied discount is a Line Item discount

Step 3 if the applied discount is a CSR Discount or Order Discount

#### Step 2 If the discount is a Line Item discount

Checks if Discount Amount Calculated By Application > Line Item’s MAD. If the discount amount calculated by the application is greater, then follows Step 2.2 and the following steps, otherwise follows Step 2.4 and the following steps

Sets Discount Amount Of Line Item For The Applied Discount = Line Item’s MAD

Follows Step 5

Sets Discount Amount Of Line Item For The Applied Discount = Discount Amount Calculated By Application

Follows Step 5

#### Step 3 If the discount is a CSR Discount or Order Discount

Checks if Discount Amount Calculated By Application > Subtotal’s MAD. If the discount amount calculated by the application is greater, then follows Step 3.2 and the following steps, otherwise follows Step 3.4 and the following steps

Sets Discount Amount Of Subtotal For The Applied Discount = Subtotal’s MAD

Follows Step 4

Sets Discount Amount Of Subtotal For The Applied Discount = Discount Amount Calculated By Application

Follows Step 4

#### Step 4 Distribute discount amounts

Calculates Discount Multiplier (DM) using this formula- Discount Amount Of Subtotal For The Applied Discount / Subtotal’s MAD

Calculates every line item’s distributed discount amount using this formula- DM * Line Item’s MAD

Follows Step 5

#### Step 5 Calculate Maximum Applicable Discount (MAD)

Calculates every line item’s new MAD using this formula- Line Item’s MAD - Calculated or Distributed Discount for the line item

Calculates subtotal’s new MAD using this formula- Subtotal’s MAD - Calculated Discount for the subtotal

Follows Step 6

#### Step 6 Apply CSR Discount again

If during Step 1, previously applied CSR discount was not removed (for a scenario when CSR discount is applied), then follows Step 7, otherwise follows Step 3

#### Step 7 Calculate discount amounts for Order Summary

Calculates the value of “Discount” displayed in order summary using this formula- Total Line Item Discount + Total Order Discount

Calculates the value of “CSR Discount” displayed in the order summary

### Steps Followed To Calculate And Distribute Discount Amounts For Shipping

Whenever a new eligible shipping discount (Promotion or Coupon) is applied while creating an Order from the admin application or web store, or while managing an Order from admin application, the Znode application performs the below steps to decide the maximum discount amount that will be applied and distributed among the line items:

#### Step 1 If the discount is a Shipping Discount

Checks if Discount Amount Calculated By Application > Total Shipping’s MAD. If the discount amount calculated by the application is greater, then follows Step 1.2 and the following steps, otherwise follows Step 1.4 and the following steps

Sets Discount Amount Of Total Shipping For The Applied Discount = Total Shipping’s MAD

Follows Step 2

Sets Discount Amount Of Total Shipping For The Applied Discount = Shipping Discount Amount Calculated By Application

Follows Step 2

#### Step 2 Distribute discount amounts

Calculates Discount Multiplier (DM) using this formula- Discount Amount Of Total Shipping For The Applied Discount / Total Shipping’s MAD

Calculates every line item’s distributed discount amount using this formula- DM * Line Item Shipping’s MAD

Follows Step 3

#### Step 3 Calculate Maximum Applicable Discount (MAD)

Calculates every line item shipping’s new MAD using this formula- Line Item Shipping’s MAD - Calculated or Distributed Shipping Discount for the line item Shipping

Calculates Total Shipping’s new MAD using this formula- Total Shipping’s MAD - Calculated Shipping Discount for the Total Shipping

Follows Step 4

#### Step 4 Calculate discount amounts for Order Summary

Calculates the value of “Shipping Discount” displayed in order summary using this formula- Sum of Line Item Shipping Discounts

## Example Of Discount Distribution Workflow

### Discount Details:

Sequence of application | Discount | Discount Amount/Percentage | Criteria |

1 | Amount Off Order promotion | $150 | Minimum order amount = $150 |

2 | Percent Off Category “Power Tools” | 10% | Minimum order amount = $0 Applicable on “DeWalt 1/4 Impact Driver” |

### Cart Details:

Product | SKU | Unit Price | Quantity | Total (Unit Price * Quantity) |

Demolition Gloves | z-2100010 | $50 | 1 | $50 |

DeWalt 1/4 Impact Driver | z-2100015 | $89 | 1 | $89 |

Subtotal | $139 | |||

Tax | $14 | |||

Shipping | $5 | |||

Order Total | $158 |

### Maximum Applicable Discount (MAD) amounts:

Demolition Gloves’s MAD is $50

DeWalt 1/4 Impact Drive’s MAD is $89

Subtotal’s MAD is $139

### Discount Distribution:

#### Discount 1: $150 Off Order

Step 1: No CSR Discount was applied previously

Step 2: Not a line item discount

Step 3: Since the calculated order discount is greater than Subtotal’s MAD, therefore Order Discount = Subtotal’s MAD = $139

Step 4: Discount Multiplier (DM) = $139/$139 = 1

Line item order discount for Demolition Gloves = 1 * $50 = $50

Line item order discount for DeWalt 1/4 Impact Driver = 1 * $89 = $89

Step 5: New Line item’s MAD for Demolition Gloves = $50 - $50 = $0

New Line item’s MAD for DeWalt 1/4 Impact Driver = $89 - $89 = $0

New Subtotal’s MAD = $139 - $139 = $0

Step 6: Since no CSR Discount was applied previously, therefore, it should not be applied again

Step 7: Discount =$139

#### Discount 2: 10% Percent Off Category “Power Tools”

No further discounts are applicable since MAD for DeWalt 1/4 Impact Driver is $0. Therefore the final Cart Details are: