1

Brief:

  • Product with SKU "sample" has a unit price of £0.00
  • Once quantity > 4, product unit price is £2.50
  • First four remain free. E.g if five in cart = (4 x £0.00) + (1 x £2.50).

Currently I have the first two requirements working, I can change the price of a particular product once there are more than 4 items, my current problem is that because the unit price changes, it counts for the four "free". So currently 5 samples bill at £12.50, instead of £2.50.

You can see my rules set up here: rules problem

The easiest solution would be to apply a discount of £10.00 to the cart, but I can only see options to alter a unit price of a line item, rather than applying a discount to the order.

How should I do this?

Possible solution avenue

I added a second action "Add line item to cart" and created a product with value of -£10.00. The problem here is that when the quantity is reduced to 4 or below, the line item remains. I cannot see a rule option to then remove that line item.

  • I would suggest you create a custom Rule action for your use case. – daviedos Mar 9 '15 at 19:46
  • What you are trying to do is really hard. Question: is 5 the maximum quantity? If it is that makes things easier. If it isn't, that makes this a very hard problem. – Brady Mar 13 '15 at 16:59
  • Create a custom rule action. It's going to be simplest way. – Matt Glaman Mar 13 '15 at 18:12
  • 1
    If you're willing to implement a hook from the Commerce API you could use a hook like hook_commerce_product_calculate_sell_price_line_item_alter(). – montaigne Mar 17 '15 at 1:49
0

You can add a custom rules condition for line item which will check next:

  • if the amount of items in cart is more than 4
  • if the current line item position is greater that 4 (load cart, sort cart line items by created date)

Use the custom condition in pricing rules for line item.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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