Jump to content

[SOLVED] Allow only one coupon code


yay
 Share

Recommended Posts

Is there any quick way to restrict customers from using more than one coupon code?

 

I know about the "Compatibility with other cart rules" in the Conditions tab but that's really not a great option when dealing with hundreds of coupons. Quite time consuming to add a new coupon and then have to go through all the old ones and remove the new coupon from the compatibility setting.

 

Could this for example be restricted in the checkout template or in some other neat way? 

 

Using v. 1.5.6.

Edited by yay (see edit history)

Share this post


Link to post
Share on other sites

 

you can do it with phpmyadmin database manager

in sql query tool run this query:

UPDATE ps_cart_rule SET cart_rule_restriction = 1

Thanks for the quick reply. This however doesn't seem to help, I can still combine coupons. And this would have to be done every time a new coupon is added right? 

Share this post


Link to post
Share on other sites

Maybe not the best solution but you could make a module to hookshoppingCart and check how many cart rules the cart has, and remove all but one.

The you may need to reload the page to see the modification.

We have something similar to offer a gift choice to first time customers.

Share this post


Link to post
Share on other sites

Seems you also have to remove the (new) cart rules that are written in ps_cart_rule_combination

 

WARNING! Hacking your database can currupt it. Always backup before trying anything like SQL modifications/deletions!!

 

 

DELETE FROM `ps_cart_rule_combination` WHERE `ps_cart_rule_combination`.`id_cart_rule_2` = 3"

 

Where 3 is the new cart rule you added (change accordingly)

 

or, when you dont want any cart rule mixed with any other, just remove them all here.

 

DELETE FROM `ps_cart_rule_combination`

 

BUT!!! Make sure you DO set the restriction to 1 (otherwise it ignores any restriction)

 

UPDATE ps_cart_rule SET cart_rule_restriction = 1

 

(N.B. You could make a trigger, if you want to to automate this...)

 

Hope this helps,

pascal.

Edited by PascalVG
Added warning (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

  • 2 months later...
  • 3 years later...

This works for me, but has anyone created a trigger for this? I'm not familiar with that but would like to run those queries that Prestashop Fanatic detailed above at any time a coupon code is created. I can do a daily cron job but it's best to do it right away on a trigger instead.

Share this post


Link to post
Share on other sites

  • 3 weeks later...
On 5/19/2018 at 6:06 PM, TurkeyFish said:

This works for me, but has anyone created a trigger for this? I'm not familiar with that but would like to run those queries that Prestashop Fanatic detailed above at any time a coupon code is created. I can do a daily cron job but it's best to do it right away on a trigger instead.

 

Would also like to know how to set up a trigger for this solution. Tried and failed haha.

Share this post


Link to post
Share on other sites

  • 1 month later...
  • 9 months later...

for the trigger you asked for in case any one needs it 

CREATE TRIGGER `trigger_name` BEFORE INSERT ON `ps_cart_rule`
 FOR EACH ROW SET new.`cart_rule_restriction`=1 

Share this post


Link to post
Share on other sites

  • 11 months later...
On 8/22/2014 at 11:30 AM, vekia said:

you can do it with phpmyadmin database manager

in sql query tool run this query:

UPDATE ps_cart_rule SET cart_rule_restriction = 1

Hi Vekia

You are a life saver. Thankyou verymuch. works perfectly

Share this post


Link to post
Share on other sites

  • 8 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More