Hi
After filling in the coupon code on the customer site and calculating the coupon, the coupon-field is empty again (see screenshot) so that the customer can fill in another couponcode which also can be used with the other one. You get a double reduction.

How can I hide this field when the first coupon is entered?

Kris

CommentFileSizeAuthor
coupon.png11.22 KBblueblot
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pcambra’s picture

Title: coupon field can be filled in twice » Hide coupon code form control once a coupon has been entered
Version: 7.x-1.0-beta6 » 7.x-1.x-dev
Assigned: blueblot » Unassigned
Category: bug » feature

Definitely not a bug report, you want that the form dissapear once you enter a coupon, that's a feature request as the user should be able to introduce as many coupons as they want...
You can play with the code that applies the coupon to set an #access none once the button has been pressed.

Setting as a feature request to see if anyone else is looking for this.

aidanlis’s picture

I'm definitely looking for this. Unfortunately changing the Coupon entity reference to be single valued causes the rules to break.

pcambra’s picture

I guess it could be a setting in the checkout pane

aidanlis’s picture

Here's a rule:

{ "rules_check_for_existing_coupon" : {
    "LABEL" : "Coupon: Limit checkout to a single coupon",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "commerce coupon" ],
    "REQUIRES" : [ "php", "rules", "commerce_coupon" ],
    "ON" : [ "commerce_coupon_validate" ],
    "IF" : [
      { "php_eval" : { "code" : "if (!empty($commerce_order-\u003Ecommerce_coupon_order_reference[LANGUAGE_NONE][0][\u0027target_id\u0027])) {\r\n  return TRUE;\r\n}\r\nreturn FALSE;" } }
    ],
    "DO" : [
      { "drupal_message" : {
          "message" : "Sorry, you can only use one coupon per order!",
          "type" : "warning"
        }
      },
      { "commerce_coupon_action_is_invalid_coupon" : [] }
    ]
  }
}
vadim.eremeev’s picture

@aidanlis thanks for rule, works very good. Just one issue: it shows 2 messages (one warning and one error) together but would be nice somehow just show one (which is warning and can be configured from rule). What do you is there way to do it without css? Maybe some code patching

blueblot’s picture

@aidanlis - rule works nice, thx

maybe the 2 messages aren't necessary if the coupon field was not shown after filling in the first coupon.

Matter is how to hide this field the second time?

blueblot