Using Commerce Discount and Commerce Discount Extra modules there is no problem to set discount rule conditions for product type and quantity. This way I can set up 20% off discount that is applied for a cart line item when this line item has specific product type and quantity more than one. 20% off discount is then calculated for this line item and multiplied by quantity.

However, my need is to apply such discount not to each item from line item quantity. I simply want to exclude applying discount for one (first one) on the basis: 0,2*(n-1)*X where n is qty and X is product base price.

The problem is that line item discount type in Commerce Discount module is calculating before quantity calculation (only for qty of 1) and proper price component is added to line item price.

The solution I've tried was to divide calculated discount (0.2*X/n) but the result calculated for quatity 3 or 6 or 9 is inaccurate (wrong, decimal number).

Is there a hook or other solution that can allow me to "return" the part of discount that should not be applied, or am I simply missing something and there is a more natural way to achieve what I described (for example, the order discount rule)?

1 Answer 1


You should be able to do this out of the box if you have the Commerce Discount Extra module installed. The offer type to use is Per-quantity product discount (% off). This offer type (and the other per-quantity offer types) was created to support BOGO style offers (buy 1, get 1 free), but we developed them to support any type of discount for any number of matching products.

In your case, you'd set the "Buy #" to 1 and the "Get up to #" to a very high number... whatever you consider reasonable for the quantity you'd expect to discount. This will result in the creation of a new discount line item.

Note that the pattern for matching products will be SKU based or product category based.

  • Hi Ryan, thank you very much for help. Commerce Extra was the first module I tried, but as you said "pattern for matching products will be SKU based or product category based" and my situation is that all products comes from the CRM system. Imports are few times a day. Categories are shared between few types of products and I want to apply discount to only one product type. In my opinion SKU and category patterns are not suitable in this situation. That is why I was looking for "Product type" based discount solution. Do you see any solution, including code modification?
    – dubwise
    Jan 18, 2017 at 9:07
  • 1
    Sounds like it would require a customization to the matching products, then. The quickest thing to do if you aren't concerned about creating a merchant-facing user interface for this would be to hook into hook_commerce_discount_per_quantity_manifest_alter(). For more information refer to the docs in commerce_discount_extra.api.php. Jan 18, 2017 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.