Explanation as to why!
Basically, if you have a coupon set up to give new customers 10% off there first order, there is nothing to stop that customer opening another account (because it will be a new customer_id number) & then using the coupon code again on the next order.
It is quite surprising how many people will do / try this to save a few £££'s & it works because this part of the code in catalog/model/checkout/coupon.php...
Code: Select all
SELECT COUNT(*) AS total FROM `coupon_history` ch LEFT JOIN `order` o ON(ch.order_id=o.order_id) LEFT JOIN `address` a ON(o.shipping_address_1=a.address_1) WHERE ch.coupon_id = '" . (int)$coupon_query->row['coupon_id'] . "' AND ch.customer_id = '" . (int)$this->customer->getId() . "'");
I have thought of LEFT JOIN the coupon_history with the 'order' & also 'address' like this...
Code: Select all
SELECT COUNT(*) AS total FROM `coupon_history` ch LEFT JOIN `order` o ON(ch.order_id=o.order_id) LEFT JOIN `address` a ON(o.shipping_address_1=a.address_1) WHERE ch.coupon_id = '" . (int)$coupon_query->row['coupon_id'] . "' AND o.shipping_address_1 = a.address_1