Can I create a discount that will/won't be applied to certain products?

Can I create a discount that will/won't be applied to certain products?

This article contains instructions on how you can limit discount application to specific products. This approach is universal, and can be used not only in promotions from Amasty modules, but also in default cart prices rules.
If you can't find the product attribute that you'd like to use among available cart price rule conditions, follow this guide to add it to the list.

Conditions vs. Actions

To create a correct cart price rule, it is important to note the difference between Conditions and Actions tabs of a cart price rule - both of them have a condition tree, but they're used for different purposes. In Conditions tab, you can define when a cart price rule will be activated, while in Actions tab you define what products the discount will be applied to. 

One of the most common misconceptions is adding a product to the wrong tab. For example, you want to add your discount to Bags category only, and define it in Conditions tab, leaving Actions tab empty:




When this discount is tested with a mixed cart, you may notice that the discount got applied not only to Bags, but to other products as well:



This happens because the conditions' tree in the Actions tab is empty, so the discount applies to all products in cart. The solution here is to move the Category condition from Conditions tab to Actions tab:



And then the discount will be applied according to expectations, i.e. to Bags category only:



Knowing the main difference between these tabs, you can tailor promotions to your preferences. Conditions tab can be used to define what products need to be added to cart (what address should be used, what subtotal/weight/item quantity an order should contain, etc.). Actions tab can be used to determine what products will have the defined discount. As the main focus of this article is applying discounts to certain products, examples below will demonstrate Actions tab; however, the overall process of including and excluding products via conditions' tree will identical for the Conditions tab as well.

How to include products

If only one value of the attribute needs to be included (apply discount to certain color, SKU, category, etc.), you may use the is operator for that purpose:

For some attribute types, like Multiple Select for example, you can use the is one of operator if more than one attribute option needs to be listed:

As for those attribute types that cannot use is one of operator (for instance, Dropdown attribute type), it is necessary to list each attribute value on a separate line using is operator and define ANY operator instead of ALL:

For text attributes, like Text Field or Text Area, you can use the contains operator for less strict matching and broadening the list of products that match the condition. Is and is one of operators require strict matching to mark the condition as valid, i.e. if you define a condition "SKU is promo", then this condition will be valid only for one product that has the exact "promo" SKU in its settings. If you need to apply a discount to all products that have "promo" in their SKU instead (like "bag-promo" or "watch-promo"), contains will be a better match:
 
It is important to note that, if several contains conditions need to be used, they cannot be defined in one line, because Magento won't recognize them as separate entities. In such situation, all conditions need to have their own condition line, with ANY operator at the top:


How to exclude products

For each option of including products that were mentioned above, there's an opposite operator that allows to exclude products from your cart price rule conditions. For instance, if the rule should be applied to all products except the ones with certain attribute value, the is not operator is used:

Products from the range of several certain attribute values can be excluded using the is not one of operator:

And products with text attributes can be excluded with the help of the does not contain option: