I have observed that customers can no longer apply a specific promocode to their orders although the uses registered per coupon are lower than the value set in the rule. The only way I have to solve the issue is to increase the value for uses per coupon (uses per customer is set to 1 always).

At reviewing the DB, I see that coupon is used in the sales_flat_quote as well in sales_flat_orders. Don't know if this is the expected behaviour (summing up quotes + orders for uses calculations) or if there's a bug I should report / correct.


In order to see how Magento checks if a coupon can be applied you need to look into Mage_SalesRule_Model_Validator in the _canProcessRule($rule, $address) method.

    if ($rule->getCouponType() != Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON) {
        $couponCode = $address->getQuote()->getCouponCode();
        if (strlen($couponCode)) {
            $coupon = Mage::getModel('salesrule/coupon');
            $coupon->load($couponCode, 'code');
            if ($coupon->getId()) {
                // check entire usage limit
                if ($coupon->getUsageLimit() && $coupon->getTimesUsed() >= $coupon->getUsageLimit()) {
                    $rule->setIsValidForAddress($address, false);
                    return false;
                // check per customer usage limit
                $customerId = $address->getQuote()->getCustomerId();
                if ($customerId && $coupon->getUsagePerCustomer()) {
                    $couponUsage = new Varien_Object();
                        $couponUsage, $customerId, $coupon->getId());
                    if ($couponUsage->getCouponId() &&
                        $couponUsage->getTimesUsed() >= $coupon->getUsagePerCustomer()
                    ) {
                        $rule->setIsValidForAddress($address, false);
                        return false;

Magento will check the usage limit and the times used of the coupon from the salesrule_coupon table. It will also check the usage per customer from the salesrule_coupon_usage table.

The times_used column of both tables is updated by Mage_SalesRule_Model_Observer observer on the sales_order_place_after event. So the coupons that are used in quotes are not considered.

If you've set the uses per customer value to 1, then a customer will only be able to use that coupon for one order (even if the order gets cancelled).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.