I created a new type of coupon. Add to rule (commerce_discount_rule_discount_mycoupontype) condition - "Coupon code for a particular discount has been added to an order". It turns out that this condition does not work correctly.

This occurs because:

function commerce_coupon_code_grants_discount($code, $discount_id) {
  $query = new EntityFieldQuery();
  $results = $query
    ->entityCondition('entity_type', 'commerce_coupon')
    ->propertyCondition('type', 'discount_coupon')  // Always only one type of coupon usage.
    ->propertyCondition('code', $code)
    ->propertyCondition('status', TRUE)
    ->fieldCondition('commerce_discount_reference', 'target_id', $discount_id)
    ->execute();

  return !empty($results['commerce_coupon']);
}

Ie always a request is made for one type of coupon.

Comments

kv4 created an issue. See original summary.

konstantin che’s picture

konstantin che’s picture

Status: Active » Needs review
konstantin che’s picture

I'm not sure, but maybe in this case, we can simply remove the condition

  ->propertyCondition('type', $coupon_type)

Because the code that clearly points to the coupon.

konstantin che’s picture

torgospizza’s picture

This seems like a reasonable approach... however I would be interested to see if this conflicts with Commerce GC which creates a new coupon type called "giftcard_coupon".

torgospizza’s picture

konstantin che’s picture

Possible duplicate: #2568749: Other coupon types cannot be redeemed

I think this is not the same. (https://www.drupal.org/node/2568749#comment-10553610).

About that:

This seems like a reasonable approach... however I would be interested to see if this conflicts with Commerce GC which creates a new coupon type called "giftcard_coupon".

I have unfortunately not possible to verify this.

But if you check, it will be very good!