3

Our store is running coupon promotion where the coupon is good until the end of the year. Let’s say the code is ENDOFYEAR (-25%). We’re also running a one day promo next week Monday with code SUPERMONDAY (-40%). What will happen if a user submits both codes? We want to ensure that only the code with the greatest discount is applied and that codes are not added together resulting in a 65% discount.

3

In Cartthrob you can only apply one coupon code to your cart at a time.

You'd need to provide a way for your user to remove the code and apply a different one instead.

| improve this answer | |
5

Discounts are cumulative, where by default Coupons are not.

HOWEVER, You can also change a hidden configuration variable to allow multiple coupon code usage.

in cartthrob/config/config.php

Change: 'global_coupon_limit' => '1',

To whatever number you want.

| improve this answer | |
0

Further to Chris' answer, I've just found that changing the value in the config file is completely ignored. Using CT 2.7.

More to the point, when you call to override the limit in the add_coupon_code method, the check either replaces the coupon_codes array, or adds a new coupon code indefinitely, ignoring the limit.

The workaround I've settled on is to override the config, and then change the conditional.

In file cartthrob/cartthrob/core/Cartthrob_cart.php at line 385:

public function add_coupon_code($coupon_code)
{
    if ($coupon_code && $this->core->validate_coupon_code($coupon_code))
    {
        // Override coupon limit as settings in config are ignored.
        $this->core->store->override_config(array('global_coupon_limit' => '2'));

        //in the case of a coupon limit of 1, we'll overwrite the coupon code
        // else we'll only add the code if we've not reached the limit
        if ($this->core->store->config('global_coupon_limit') == 1 && count($this->coupon_codes()) >= 1)
        {
            $this->coupon_codes = array($coupon_code);
        }
        elseif(count($this->coupon_codes()) < $this->core->store->config('global_coupon_limit'))
        {
            if ( ! in_array($coupon_code, $this->coupon_codes))
            {
                $this->coupon_codes[] = $coupon_code;
            }
        }
    }

    return $this;
}

One issue with this is that there's no feedback for the user that they've added too many coupon codes. Works for my purposes, but worth bearing in mind.

| improve this answer | |

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.