This is tutorial #14 in the Drupal Commerce tutorial series. In the previous article, we added a flat shipping rate to all orders.
In this article, we will apply a flat discount of $6 to all orders above $50, irrespective of the shipping address. This is how my final screen looks after the discount has been applied:
For this purpose, I have downloaded and unzipped the Discount Commerce module (https://www.drupal.org/project/commerce_discount). This module provides us with an excellent UI to configure discounts for shopping carts.
Note that you will have to download and unzip Inline Conditions module (https://www.drupal.org/project/inline_conditions) before you enable Discount Commerce.
Let’s go ahead and enable these modules. Click “Modules” on the top-level menu:
Search and enable “Inline Conditions”:
Click “Save configuration”. Search and enable the following modules:
- Commerce Discount: The primary module responsible for providing us with the UI.
- Commerce Discount Date: This module allows us to add date functionality for discounts, allowing us to specify when a discount will expire.
- Commerce Discount Usage
A new “Discounts” link will appear in the “Store” section. Click it:
Click “Add discount”:
Add a new discount for your Ecommerce store. In our case, I am creating a flat $6 discount for all orders above $50. These are the fields you will encounter in the new page:
- Admin title: The title that will be associated with the discount for back-end purposes.
- Name: The title that will be seen by front-end users.
View the screenshot below for more details:
- Choose discount type: Specify whether the discount is based on the order or product. In our case, the discount will be based on the order’s total value:
- Order discount conditions: The values I provided in the dropdown – “Total amount“ and “greater than” are self-explanatory. I typed in 50 for the USD field. Enter an amount of your choice:
- Maximum overall usage: How many times should the discount be used?
- Maximum usage per customer: How many times does each user get to use the discount?
I have left both fields blank because I am not going to monitor discounts based on usages.
I want the discount to be used for a month, irrespective of how many times they are used:
Click “Save discount” at the bottom of the page:
The discount has been saved:
I’m going to check out my cart to verify whether the discount works smoothly:
As can be seen in the screenshot below, $6 has been deducted from my final order worth $50: