Hello,

On a fresh Kickstart2 install, I installed the Coupon + Coupon fixed amount module.
I created a coupon "TEST1" that gives 20€ discount on an order (basic usage)

On the order creation ui (admin/commerce/orders/add), I added a line item with a product for 25€.
Then I added the TEST1 coupon code in the autocomplete field under the Coupon fieldset.
As a result, the coupon usage count is updated correctly in the Coupon admin UI, but the order total amount didn't change (It should be 25€ - 20€ = 5€, while it's still 5€).

So here's the question / issue :
- Is it the intended behavior ? (let an admin "attach" a coupon code to an order but no applying it automatically)
- Is it a bug ? (When an admin enters a coupon code in the order edition ui, the coupon should be automatically applied to the order)

Many thanks !

Comments

jessepinho’s picture

I'm having the same issue. It seems that the problem may be that, while the commerce_coupon_order_reference field is getting filled out (because you're adding "the TEST1 coupon code in the autocomplete field under the Coupon fieldset," as you wrote above), the commerce_coupon_reference field (i.e., the field attached to coupon line items) is NOT being filled out, because there's no way to do this when adding a coupon line item via the admin item. Please advise as to how this can be fixed!

jessepinho’s picture

Category:support» bug

Marking this as a bug report, as adding a coupon via the admin UI should result in the order being discounted by the coupon amount.

jessepinho’s picture

I'm currently working on a pretty complicated Rules rule to make this work properly. It'd be pretty simple—just add a coupon line item before an order is saved, if the coupon order reference field is populated—except that, on additional saves, additional coupon line items are added to the order. Trying to figure this out.

pcambra’s picture

Status:Active» Postponed (maintainer needs more info)

I'm not sure what's the problem here, just tried to reproduce this and the behavior is what I'd expect, I add the coupon in the admin ui of orders and it refreshes correctly.

amillionmonkeys’s picture

I'm having this same issue. When adding a coupon using the admin UI, no line item is added. Any guidance would be greatly appreciated.

flo81’s picture

Issue summary:View changes

I'm having a similar problem with Commerce Discount : when creating an order with admin UI my discount rules are not applied.

IMHO the problem is that the "Calculate a product sell price" doesn't fire when saving an order with the admin UI, so Discount or Coupon rules are not called.

markbannister’s picture

Same issue. This seems fairly critical to me......

markbannister’s picture

In order to get the rule to fire you must set the order status to "Checkout: Checkout" and then save the order.

Never mind -- sorry can't duplicate this -- may have been confused.
The rules do fire, you can see that in the rules log and they do seem to evaluate to true (if I understand the log correctly)

OK, got it, sorry again, Order must be in status Checkout: Checkout and order owned by an administrator.

markbannister’s picture

Been looking at the rules evaluation log, and it looks to me as if the rules are evaluating to true. (I'm assuming the log is appended to...anyone know how to clear it?)
Steps, create an order in admin ui.
make it's status checkout, add a valid coupon, save the order.
The coupon is not applied but I see this at the end of the log (actually it's in there multiple times but again I don't know how to clear it)

Reacting on event Apply a discount to a given order.

0 ms Reacting on event Apply a discount to a given order.
0.104 ms Evaluating conditions of rule Lobster Dinner Coupon. [edit]
" Executing and Conditions for Discount coupon coupons. [edit]
0 ms Executing and Conditions for Discount coupon coupons.
0.178 ms The condition data_is evaluated to TRUE [edit]
" Executing and AND.
0 ms Executing and AND.
0.494 ms The condition commerce_coupon_usage_evaluate_usage evaluated to TRUE
0.501 ms AND evaluated to TRUE.
0.509 ms Finished executing of and AND.
0.913 ms The condition commerce_coupon_evaluate_coupon_inline_conditions_rule evaluated to TRUE [edit]
0.978 ms The condition commerce_coupon_current_user_may_redeem evaluated to TRUE [edit]
0.983 ms AND evaluated to TRUE.
0.995 ms Finished executing of and Conditions for Discount coupon coupons.
2.236 ms The condition commerce_coupon_discount_coupon_codes_exist_on_order evaluated to TRUE [edit]
3.188 ms The condition commerce_discount_date_condition evaluated to TRUE [edit]
3.505 ms The condition commerce_order_compare_order_amount evaluated to TRUE [edit]
3.512 ms AND evaluated to TRUE.
" Rule Lobster Dinner Coupon fires. [edit]
0 ms Rule Lobster Dinner Coupon fires.
0.05 ms Evaluating the action commerce_discount_fixed_amount. [edit]
13.443 ms Rule Lobster Dinner Coupon has fired.
16.974 ms Finished reacting on event Apply a discount to a given order.

Now, I edit the order again, change the user to an admin, more logging data added (identical to the text above) but the coupon is applied properly.
I've tried setting every permission I can find that looks pertinent.

markbannister’s picture

I'm getting bad about this, sorry, but everything I posted in #9 is wrong.
The rule DOES not evaluate if the order is not owned by the current user.
When in the Admin manage order ui (admin/commerce/orders) the rule will fire for every order with status, checkout, owned by the currently logged in user, and having a coupon.
They evaluate at every reload of the Admin manager order page. (WAD?)

Reproduce:
Create a several orders in the admin order page, add items, add coupon, set status to checkout, set owner to a different admin user (admin2)
None of the coupons will be applied and the coupon rule will not evaluate (I added a status message to the rule to show the order ID and coupon and discount used)
Log out.
Log back in as admin2, go to the manage orders page, the coupons will be applied to all orders owned by admin2, in checkout.
If you added a status message (that repeats) you will see displayed all the orders ID's that are evaluated.

szczesuil’s picture

Hi, I've run up against the same wall. I need to apply coupons while logged in as an admin, placing orders for new or returning customers.

markbannister has it right (although I use masquarade).

There is a reference to a Redeem Coupon permission in the 2.x dev version. I'm assuming this added permission would solve this problem. However, there look like there are too many 2.x dev issues to go that path right now.

Has anyone else come up with a solution to redeeming coupons on orders placed when a customer phones in an order?