Developer's Toolbox: Price Rules in Magento
While working with clients over the past few months, I started to notice very similar questions being asked across the field. Regardless of the client background, they were all asking about how promotions work in Magento eCommerce development, specifically price rules. It became such a recurring topic that I decided that I could take these questions and turn them into a full-fledged eCommerce blog post. Below you will find a walkthrough explaining the functionality behind both Shopping Cart (Coupon Codes) and Catalog Price Rules.
Shopping Cart Price Rules
The most visible way of rewarding customers is by applying a discount to the shopping cart. This can be accomplished by creating a rule that discounts a product (or even the entire cart) when a condition is met, or simply by getting the customer to enter a code from the cart page. This can all be done in the admin by going to Promotions->Shopping Cart Price Rules.
Shopping cart rules are broken down into five sections: Rule information, Conditions, Actions, Labels, and Related Banners.
This section contains the basic information on the rule you are creating. Rule Name and Description are used internally to inform other administrators what your rule intends to do. A short sentence or two in the description will keep your admins from walking through the rule logic trying to understand what is going on.
The Status value in Magento design tells if the rule is enabled or disabled, while the customer group tells the system what kinds of customers the rule applies to.
The Coupon setting lets admin users decide if a coupon code needs to be applied to be eligible for the rule. If a coupon code is required, then administrators can manually enter the code to be used, or let Magento optimization generate one automatically. Uses per Customer determines how many times each customer is allowed to apply the price rule. If nothing is entered, this field is ignored.
The From Date and To Date determine the duration that the rule will be in place. If the From Date is left blank, the current date is used. If the To Date is left blank then there is no ending date for the rule. The Priority value is used to determine the order that rules are calculated, and the Public in RSS Feed determines if the rule is mentioned in the Magento feed.
This tab is the first of two logic tabs for the price rule. This section allows admin users to enter a series of conditions that decide if the rule will be applied. Rules can be applied based on product attributes, product sub-sets, cart attributes, customer segmentation, or any combination of the above.
Below is an example showing that the rule will be applied when the cart subtotal is over $200.00 and a product in the cart has a brand attribute of Dell.
The Actions tab is the second logical tab and is actually broken out into two sections. The first section is where the actual price discount information is entered. Users can enter the type of discount being applied. (Percentage, Fixed Amount, Fixed Amount for the Entire Cart, and Buy X get Y free).
The discount value varies depending on the type being applied. If a percentage is being discounted, the integer entered will be converted to a percentage and removed from the cart. If either fixed amount option is selected, the value is the amount that will be taken from the order. If the Buy X get Y Free option is selected, the value is the Y variable.
The max qty field is used by admin users to put a limit on the products that can receive a discount. If a customer buys ten of an item and should only receive a discount for 5 of them, 5 is the value that should go in this field.
The remaining options are self explanatory via their labels. They decide if the discount can be applied to the shipping price, allow the free shipping method to appear on the cart, and give the ability to continue processing rule or to stop after this one is applied.
The second section of the actions tab determines which products in the cart are given this discount described in section one. The logic involved here is very similar to that in the Conditions tab and can be calculated in the same manner. If this section is left blank, the discount will be applied to every product in the cart.
This section is the easiest to understand but very important to the Price Rule functionality. The text entered in this section is what the customer sees on the cart page when the discount is applied. The verbage should be short and to the point, but still give the customer an idea as to what the rule is doing.
This last section is reserved for users who use the Magento Enterprise Edition. This last tab allows customers to select previously created banners and associate them to the current price rule. This in conjunction with some modifications to your store’s theme gives you an entire new level of dynamic, targeted content for your customers.
Catalog Price Rules
I know that everyone’s brain is probably reeling from the information overload that is associated with learning how the cart price rules work, but we need to go just a little further and cover Catalog Price rules too. The good news is that this type of price rules works very similarly to the cart rules. The main difference here is that when these rules are saved, they actually need to be applied to the catalog to take effect. These rules are managed from the Promotions?Catalog Price Rules page.
When creating a Catalog rule, you will notice that almost all of the tabs are the same. The label tab is gone because no labels are used when making catalog price changed. However you will notice that all other tabs still exist.
The only new functionality resides in the Actions tab. In addition to the apply options, admin users are able to apply discounts to subproducts. If this is set to ‘no’, then only the parent price will be discounted. However if the value is set to yes, then a new field appears that allows users to set an additional discount for the child prices. This new functionality is only used if a product in question has children (such as the configurable product type).
So there you have it. We’ve gone over every step of the price rule process. In the last few minutes we created a new cart rule; added the conditional logic; applied a 20% discount; restricted what product types get the discount; and applied a label for the customers on the checkout page. We’ve also taken a look at the catalog price rules and explained the differing functionality found there. The example rule used in this post contained simple logic that applied a 20% discount. But the logical tabs found in the price rules allow for far more complicated conditions and combinations that can be applied. When it comes to creating promotional rules in the Magento development the sky truly is the limit.