Discounts


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 ConditionsA 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:

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

Date Condition

Cart Included / Excluded Condition

There are two types of cart item conditions. Cart Includes and Cart Excludes.

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. 


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:

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

Cart Shipping Action

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. 

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:

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.


The final switch will check if this Discount is activated (even if it's action does nothing, e.g: "take 0 dollars off the cart"), it will stop all other discounts below it's own priority and exit the discount logic after it performs it's action. The final switch is useful if you have large discount which you do not wish other discounts to additionally add to.

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:

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:

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:

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

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:

insertVoucherCode.html
<{$user->setField('user_custom1''FirstCheckoutVoucher')}>
<{$user->update()}>
removeVoucherCode.html
<{$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.