Discounts
- Overview
- Discount Waterfall
- Discount Coupon
- Creating a Discount
- Adding Discount
- Pricing Condition
- Date Condition
- Cart Included / Excluded Condition
- User Condition
- Maximum Usages Condition
- Discount Action
- Cart Pricing Action
- Cart Shipping Action
- Extra Cart Item Action
- Surcharge Action
- Ordering, Looping and the Final Switch
- Discount and Vouchers
- Show Discounts Which are Applied
- Creating a Discount
- Discount Examples
- Example 1: One Product Check Take 20 Off Total
- Example 2: Quantity Check with a Price Check and Apply Discount to Only One Cart Item
- Example 3: 10% of Shipping Rate if Category Item Found with Three Quantity
- Example 4: Check Date and Apply 5 dollars off if before Feb 2017
- Hooks and Discounts
- Creating a Discount
- First Checkout Discount
- Create the Templates
- Create The Hooks
- Create the Discount
- Final Test
- First Checkout Discount
Find Discounts under Transactions → Vouchers. Discounts will only show for Cart3. Check your 'centre options' to ensure you have Cart3 enabled.
Overview
Discounts allow any eCommerce website to automatically apply a discount to the cart based on multiple rules (Conditions) and an Action (the Discount itself).
Discounts do not require any integration changes to work and will just work inside of Cart3, once a Discount has been published.
Discount | A collection of Conditions and a single Action |
Discount Conditions | A set of rules that all must pass true in order for the Action to apply. |
Discount Action | The amount to discount, which items to discounts and how often it can run |
Every Discount must at least have one Condition and an Action configured before you can publish it.
Discounts are calculated on each cart load, and not just loaded at the very end of checkout.
Discount Waterfall
A Discount Waterfall will take the modified price of the cart items into consideration. Typically a Discount will operate on the base price and does not factor in any prior discounts who may have run.
Discount Coupon
The Coupon switch allows you to configure if this discount is activated via a coupon code on checkout. If not enabled, it will operate as a normal discount which will always run in the background (if published)
Creating a Discount
The Discount itself is just a collection of Conditions with an Action.
All we give a Discount is a name, description (optional) and set it as a Coupon or not. Coupons are Discounts which get activated only when a customer types in a code during checkout. Typically we leave this unchecked. Refer to Discounts and Vouchers for more information.
Once a Discount is published it is active. In order to add an new Discount, click Add a Discount in the top right of the Discounts tab. you will be shown this window.
Click Save, which will insert a new Discount
A view of a simple Discount and the default Voucher Discount shown.
Adding Discount Conditions
Discount Conditions perform checks on the current cart. A Discount can have many conditions, all of which have be true in order for the discount to apply. This allows Discounts to check for complex cart combinations, while keeping the configuration simple.
Conditions can check for the following:
- Price (greater than / less than / equals)
- Selected items (products / bundles / categories)
- Date (greater than / less than / equals)
- Item Quantity on a included / excluded Cart Item.
- Item Quantity on a included / excluded Product Category
- Item Quantity on a included / excluded Product Category and it's Category Children (any products which belong to a child of the selected category)
Once all Conditions have been met, the Discount Action will apply.
In order to Add a Discount Condition, hover over your new Discount and select Conditions. Then click Add Condition in the Conditions table shown.
PricingCondition
- Description: a optional description of what this condition does
- Type: (Price, Date, Cart Items) This Condition will check the cart price
- Operator: (greater than, less than, equals to, less than or equals to, greater than or equals to) The sign used to check the on the value. for example; type: price, operator: greater than: value: 1. (price is greater than one)
- Value the value to check
Date Condition
- Set Date: Select the Date which this condition will check based on the operator value
Cart Included / Excluded Condition
There are two types of cart item conditions. Cart Includes and Cart Excludes.
- Cart Includes allows you to check for current cart items with the resulting being a pass for this condition.
- Cart Excludes allows you to check for current cart items who will fail the condition and stop it processing.
- Minimum Price The total minimum total price of all valid cart items (items who are not part of the excluded list).
- Maximum Price The total maximum total price of all valid cart items (items who are not part of the excluded list).
- Minimum Quantity The total minimum quantity of all valid cart items (items who are not part of the excluded list).
- Maximum Quantity The total maximum quantity of all valid cart items (items who are not part of the excluded list).
- Include Category Children: Any products/bundles found in this category or any of its children.
- Items Included: A list of Items this condition applies to. Products, Bundles and Categories are supported. If a item in the cart is found in this list it will pass this part of the condition.
- Items Excluded:A list of Items this condition does not apply to. Products, Bundles and Categories are supported. If a item in the cart is found in this list it will not fail the condition, it will however remove it from the other valid checks happening.
Note: Minimum Quantity can allow you create conditions for generic products on a category, e.g: if cart contains any four products, just set the parent category and the quantity to four.
User Condition
Perform various checks on the current logged in user. None of these checks will apply to a guest user.
- User Groups Included: The User must be part of at least one of the following groups. Not all groups are necessary.
- Custom Field (1-5): Set the value that this value checks for. It can work with numbers or strings. Default Ignore which means it is not looked at.
- Number of Previous Orders: Perform a check on the amount of orders this user has made in the past. Only orders who have status 'new' or 'completed' will be included.
- Total Spend to Date: Perform a check on the amount of orders this user has completed in the past. Only orders who have status 'new' or 'completed' will be included.
- User Registration Date: Perform a check on the date the user registered.
- User Registration Days: Perform a check on a dynamic amount of days in the past when the user registered. This will allow new users a discount, without needing the admin to constantly update the date logic.
Click Save and the window will close. Once you have added your Condition, it is automatically published. The discount does not take effect until the Discount itself is published, so you can setup your conditions without effecting your current checkout until you are ready to enable it.
Maximum Usages Condition
Define how many times this discount can run. For example, if set to one; the discount will only ever run once and then never again. This is useful for one time only vouchers.
Discount Action
This is the what actually effects the cart, everything until now was just checking if it can run. Now we edit the items within the cart and modify the final price. The action allows you select how much, what modifier and what items this discount applies to. So you can have a Condition to check for Product A, and only apply the discount to Product B.
Actions allow you to:
- Modify the cart total (total, per item) (Percentage, Fixed)
- Select which cart item to apply the discount to. (if we have more than one valid item to apply to) (products, bundles, categories, category children)
- How many times this discount can run. (if we have more than one valid item to apply to)
- Modify the cart shipping total.
- Which Shipping Rate to apply to
- Allow the Cart a free Item - this item will not be charged.
- Limit the liftime discount that can be applied.
Select the type of the Action from Pricing, Shipping and Extra Cart Item.
In order to setup a Discount Action, hover over a Discount and select Action. Once you click this button, a modal window will be shown like below. Using this window you can change the discount properties and select who it applies to.
Using the Type drop down (pricing, shipping, extra item), you are shown the following:
Cart Pricing Action
- Amount: The Amount to discount using the Modifier on Cart Total
- Modifier: Percentage or fixed, used by the amount.
- Limit: If we have more than one Item in the cart which the Action can apply to, this limit will determine how often the discount will apply. Default is one.
- Apply To: Which cart item to apply to first. All Cart Items or Selected Cart Items.
- Include Category Children: Any Categories listed in the below tables will search their children categories for relevant cart items.
- Items Included: This Actionwill only apply to these items in the Cart. This is included here, along with the conditions as you may want the condition to check of Product A and only discount Product B in the cart.
- Items Excluded: Any Items in the cart that are part of this list will not be discounted.
Cart Shipping Action
- Amount: The Amount to discount using the Modifier on Cart Shipping Total
- Modifier: Percentage or fixed, used by the amount.
- Shipping Rates: Only apply Action if chosen shipping rates are selected. Leave blank for any shipping rate.
Extra Cart Item Action
Thisaction allows a free item to be added to the cart, rather than affecting the existing items. This is useful in buy X get one free or free gift scenarios. Once this action has passed, in preview for the cart: the key: 'suggest/qualified/items' will be populated. This action will not automatically add the item your cart, instead front end code will need to be used to detect this setting and show to the user / add to the cart via ajax.
- Dropdown: Select which item(s) the customer is entitled to. These items can be pulled from the cart3 object using the suggestDiscounts() function.
Surcharge Action
This action allows an addition to be made to that cart total. The surcharge does not alter the per item price of the cart, so tax per item does not change. You can use this action if there are some conditions which need to be met but the outcome is intended to increase the cart total.
There are two Apply To options:
- Cart Total - The total supplied in the amount field will be added to the cart total. If the modifier of plus is selected then it will simply add, otherwise then a percentage of the cart total is used.
- Packages - For every packed package used by Zone Based Shipping, Apply the amount provided to the cart total. This is per package. This option allows you to add package pricing to the Core dna checkout. For example, if a checkout has two packages and the Amount is +$10, then $20 dollars will be applied.
Ordering, Looping and the Final Switch
Discounts will be looped until no more can be applied to the cart.
Discounts can be organised via the DXP, using the Priority option to the right hand side of each discount. Discounts with Priority 1 will be executed first.
Discounts and Vouchers
By Default, A Voucher Discount is shown. This Discount cannot be deleted or modified, it represents the vouchers in the left tab.
What this means is that any voucher code entered during checkout will be converted into a discount and applied, ensuring backwards comparability with Vouchers and Discounts. You can set the Priority and the Final Switch on this Discount.
Show Discounts Which are Applied
$cart3→describeDiscounts() will return all the current Discounts for you. This function is designed to return an array of English sentences describing each discount applied, with a key of what each effects.
Discount Examples
Listed below are some example Discount setups.The pictures can be used as a guide.
Example 1: One Product Check Take 20 Off Total
Problem:
Product A must be in the cart. 20 dollars off cart total
Solution:
One Condition to check for product A
Action take 20 dollars of all items
Condition
Action
Example 2: Quantity Check with a Price Check and Apply Discount to Only One Cart Item
Problem:
Product B must have quantity of 2. Cart must be of price higher than 50. Only apply to Product C, 30% off
Solution:
One Condition to check for product B with quantity of two
One Condition to check for price higher than 50
Action with product C selected, 30 value and Percentage modifier selected.
Action
Example 3: 10% of Shipping Rate if Category Item Found with Three Quantity
Problem:
Cart must contain Category One with 3 total products of any of its children. Apply 3 dollars off on two items by order of the most expensive cart items
Solution:
One Condition to check for Category One, with 3 Minimum Quantity set and Include Category Children Enabled
Action limit of 2, set order by most expensive, value of 3 with modifier of dollar.
Condition
Example 4: Check Date and Apply 5 dollars off if before Feb 2017
Problem
Date Must be before Feb 2015. 5 Dollars off entire Cart.
Solution
One Condition to check for Date less than 1st Feb 2017.
Action take 5 dollars of all items
Hooks And Discounts
First Checkout Discount
Using Discounts and Hooks we can create a simple workflow that will allow one speical discount per user on first checkout. This will all work behind the scenes and the user does not need to do anything. On user signup a hook is executed to assign a special discount code into their profile. On checkout, this user profile is checked for a code and if found, a discount is applied. On first successful checkout, this code is removed and all future checkouts will not get this discount.
In this example we will be checking Custom Field 1 for a certain string value. But this example could be used to check for certain user groups, or date registered. For now, the example will stick to a string check for simplicity.
Create the Templates
First we need to setup the small templates needed to populate the new user with the code. Under the site create the directories (sitedir/modules/hooks/templates) if it is not alreasy present. Now create two HTML files, one called insertVoucherCode.html and the other removeVoucherCode.html. Insert the following into each file:
<{ $user ->setField( 'user_custom1' , 'FirstCheckoutVoucher' )}> <{ $user ->update()}> |
<{ $user ->setField( 'user_custom1' , '' )}> <{ $user ->update()}> |
These files will insert and remove the code for the user on user creation and order complete. Now lets create the Hooks to handle these files.
Create The Hooks
Navigate the Hooks (admin_hooks) and then click Add New Hook. Select The Event 'New User' and click save. Do this again, but this time select the event 'Order Paid'.
Now click Actions under each Hook. On this screen we will add the job of running the templates created eariler.
Click Add New Action. On this screen select 'Evaluate Template' and the newly created insertVoucherCode.html in modules/hooks/templates.
Click Save and you will be retunred to the Actions screen.
Do this again, create a new Action under the second hook and select the removeVoucherCode.html. They all have same settings, it's just the templates executed and Hook event which are different. Each Hook should only have ONE action.
Once you have completed this, ensure the Hooks are published.
Create the Discount
Navigate to Discounts and click Add new Discount. Give it the name 'First Checkout Discount'.
Click Conditions under this new Discount and then click Add new Conditon.
Select User and enter 'FirstCheckoutVoucher' into Custom Field 1. Ensure the setting is Equals To.
For the Action, enter the following - 25% off all cart items.
Now Publish the Discount.
Final Test
So now you can test this process. Create a new user on your site. Now load up the new user in the DXP. The New User Hook should have activated, it should have a Custom Field 1 value of 'FirstCheckoutVoucher'
If not, ensure you Hook is published. If it is and you still do not have this value, check your Hook log (right beside Actions) and it will show the error it's hitting. Once this value is being populated, log in as that user and complete a checkout. The Discount should be applying, as it is finding this value. Complete the checkout and the Custom Field value will disappear. You can confirm your discount by viewing the order in the DXP.