I would like to create a fixed value coupon, that is only valid for orders above a certain amount. Let's say '5€ off on orders above 40€'. If a user would try to redeem this coupon on a cart with an order value of 25€, a message should appear like 'This coupon is valid only on orders above 40€'.

Any ideas on how to do this? Or are there any modules that can already do this?

Thanks

Comments

pedrop’s picture

+1
I'm looking for the same feature

Horroshow’s picture

Can anyone help? I need this feature as well.

Maybe with a rule comparing order total? But would it subtract the coupon value from the total as it should be? I will try that and report here.

strings6’s picture

I figured out how to copy the rule created by commerce_coupon_fixed_amount, and then modify the copied version to add a new condition that checks against a "Subtotal greater than" field I added to a new coupon type called "Fixed coupon by subtotal". The rule seems to work to add the coupon as a line item, but the "Granted amount" is blank for some reason. This doesn't happen with the regular fixed amount coupon, but only my modified version.

Has anyone got any idea why? Is there a second rule that updates that part or something? Does the machine name of my new coupon have to match some formula (like start with "commerce_coupon")?

Thanks!

strings6’s picture

Today I realized that the fixed rate coupon will apply even if the subtotal is less than the coupon amount, resulting in a negative order total. I would suggest that to prevent this, the module should come out of the box with a "subtotal greater than" field, and that we should figure out how to make that work. The reason being so that we can at least enter the coupon amount into that field, so that the order can't drop below $0. That new functionality would then also give us the ability to set that value to a higher number, to accomplish the goal of the original post.

And what about this scenario? Say that is all worked out, and someday we can do a coupon that is a "fixed rate if subtotal > X" and everyone is all smiles about it. What about the scenario where the coupon applied successfully because at one point an order was in fact over $X, but then AFTER the coupon is applied, the user removes items from their cart, dropping it below $X total. I haven't seen anything in the rules that would REMOVE the coupon for us now that it would technically no longer apply. So, I think fixed rate coupons really have two issues to tackle.

Thoughts?

strings6’s picture

Hello,

I read through the module code and had a revelation that all I needed to do was use the module as-is, and then make modifications to the fixed coupon fields and the conditions in the "Redeem a coupon" rule.

I added a field called "Minimum order total" to the fixed coupon type. Then I altered the rule for redeeming the coupon to check "Entity has field" on my new field and also added a price comparison that the order total is greater than the value stored in the new minimum order field.

I'm not sure why my first thought was to over-complicate things by making a copy of the fixed coupon type and rule, rather than revising the existing ones.

I still think it would be cool to update the module a bit so that the fixed coupon type had this minimum order total field by default, and the rule was setup to check for that by default too. Then the module code could perhaps be tweaked, to add logic so that the coupon is removed if the order total drops below the minimum required value. And then maybe it could also say a message on the screen about the order total not meeting the minimum requirement, like the original post suggested. At the moment, it seems that the coupon just doesn't apply, and there is no explanation on the screen.

And for people who say, "But I don't want a minimum value...", you could just put 0.00 in that field then.

Anyway, maybe food for thought for the module maintainer. Thanks.

a.hjelm’s picture

Just on the top of my head:

Wouldn't you be able to create a rule for IF order_total < [min_amount] set coupon as invalid.

Just create a new rule with the "validate a coupon" or "redeem a coupon" event (Not sure which one) using either a component checking the query or if you can put it directly into the rule.

Then for action you put "Set coupon as invalid" AND "display message" -> "This coupon is only valid for orders above [certain amount].

That way you would have to go adding anything to the coupon itself.

I will try this out when I have time and report.

joe huggans’s picture

Issue summary: View changes

#6 is what I choose to do, the only small issue that I have is that I still get the original error message generated by the action 'invalidate coupon'.

So I have setup my own error message under the actions for this rule which states "You must spend over £amount to use this coupon".

This is not ideal as like I said both of these messages are shown to the end user. My only solution right now would be to hide the original message with css by targeting that list item.

joe huggans’s picture

#5 Does seem like the proper way to go about things so I choose to give this a go for what it is worth.

doing things using strings6's method would only require one Rule to check minimum and maximum(if applies) to see if the order total falls within these values.

Then you would be able to create many coupons with different minimum and maximum order total amounts and not worry about creating a new rule each time.

joe huggans’s picture

So I have just tried this method, the event being 'validate coupon' and created an 'entity has field' under conditions using the data selector 'coupon'. This then allowed me to choose the field which I had set up under the fixed coupon type of minimum order amount.

However, I have noted that if someone applies the coupon but then removes a product (which then subsequently decreases there order total below the threshold required, i.e minimum order amount), and then returns to checkout area, the coupon is still applied to their order.

I have tried to resolve this issue by creating a new rule that removes all coupons when a product is removed from the cart but this seems to be incompatible with Commerce Ajax add to Cart module, since removing a product from the Ajax add to cart block does not trigger this event.

I raised this issue here
https://www.drupal.org/node/2501643

A workaround if you are using Ajax add to cart is to create a separate rule

Event:Before customer profile panes are displayed

Condition:Price comparison

Action:Remove all coupons from an order

stephenevans’s picture

Some of my notes as I was trying for hours to get this to work! Hope it helps someone.

#5 @string6 hit the nail on the head. It took me a while before I found this webpage to solve this problem (and then some even after I found it and to test). This should be by default in the coupon module. Just to clarify #5 for noobs like myself:
Go to Store Setting > Coupons > Fixed Coupon > Manage Field > add “Minimum order total" with "price" for data.
Then go to: Site settings Advanced settings Configuration Workflow Rules Editing reaction rule "Redeem a coupon with fixed
New Condition Data Selector “coupon” Field “Field_minimum_order_total”
Add new condition “PRICE comparison” “commerce-order:commerce-order-total” “>=“ switch to data selection “coupon:field-minimum-order-total”

#6, #7, in my opinion should be built into the module as well. Just to clarify:
So created new rule” "Coupon Validation: Check the minimum order value" event “validate a coupon” condition “entity has field” “coupon” “field_minimum_order_total” AND “PRICE comparison” “commerce-order:commerce-order-total” “<“ switch to data selection “coupon:field-minimum-order-total”actions “set coupon as invalid” and “show a message on the site” “Sorry, the minimum order total for this coupon has not been reached.” “Error”

#9, I just used your recommendation from the link and it worked. I guess I'm not using AJAX or maybe there's no other way to remove from cart unless they go to /cart:
Now people can “Hack” by adding coupon then removing items and then coupon is still in cart if order is less than coupon minimum!
Create new rule: “Remove Coupon if Min not reached after cart update” event “After removing a product from the cart” condition “none” action “remove all coupons from an order”

f1l1pp0’s picture

Thank you @stephenevans for summarizing the steps, everything worked perfectly.

Concerning #9 I have noticed that there is a second case that might be exploited to cheat the system: if the user decreases the quantity of a product in the cart, the order total might again be lower than the threshold, but the coupon is not removed from the order.

I have solved this problem by installing https://www.drupal.org/project/commerce_rules_extra and by adding a second event to the rule: "Quantity of line item has changed".

prophet108’s picture

Thank you for your work on this. #11 works if the user clicks on "update cart" but if he/she clicks on "Checkout" then the order processes the line item adjustment and goes straight to checkout without removing the coupon. f1l1pp0 - are you not experiencing the same thing?

torgospizza’s picture

You should also give Commerce Discount Extra a try. It has some nice functionality for more complex discount schemes.

NOTE: That module is only compatible with Commerce Coupon 2.x.