Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
The incorrect discount is being applied to a coupon code when that same code has been used to make previous purchases.
Scenario:
- Using a coupon of a value of $20 dollars.
- purchase an item that costs $1
- complete the purchase if needed in the transaction table
- repeat these steps one or more times to see the effect
You'll see that the discount value of the coupon never changes from $19, no matter how many times to re-apply the coupon code.
in coupon_checkoutapi the line
elseif ($coupon = db_fetch_object(db_query("SELECT c.*, tc.txnid, SUM(tc.discount) as coupon_discount FROM {ec_coupon} c LEFT JOIN {ec_transaction_coupon} tc ON c.coupon = tc.coupon WHERE c.coupon = '%s' GROUP BY c.coupon, c.operator, c.operand, c.created, c.created_txnid, c.created_vid, tc.txnid", $new_coupon))) {
if (($coupon->operator == '%' && $coupon->txnid) || ($coupon->txnid && ($coupon->operand * ($coupon->operator == '+' ? 1 : -1)) <= (float)$coupon->coupon_discount)) {
form_set_error('new_coupon', $error);
}
returns multiple rows instead of one row that contains the sum of the discounts used. Removing the GROUP BY clause will solve the issue. Don't see how having the GROUP BY clause is handy in this particular situation.
Comments
Comment #1
number3 CreditAttribution: number3 commentedThis issue may be in version 5.x-3.5 as well
Comment #2
apadernoI am closing this issue, as Drupal 5 is now not supported.