Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#2 | commerce_coupon-rules_condition_custom_coupon_type-2612484-1-7.x.patch | 1.74 KB | Konstantin Che |
Comments
Comment #2
Konstantin Che CreditAttribution: Konstantin Che commentedComment #3
Konstantin Che CreditAttribution: Konstantin Che commentedComment #4
Konstantin Che CreditAttribution: Konstantin Che commentedI'm not sure, but maybe in this case, we can simply remove the condition
Because the code that clearly points to the coupon.
Comment #5
Konstantin Che CreditAttribution: Konstantin Che commentedComment #6
torgosPizzaThis 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".
Comment #7
torgosPizzaPossible duplicate: #2568749: Other coupon types cannot be redeemed
Comment #8
Konstantin Che CreditAttribution: Konstantin Che commentedI think this is not the same. (https://www.drupal.org/node/2568749#comment-10553610).
About that:
I have unfortunately not possible to verify this.
But if you check, it will be very good!