X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Limit one coupon per customer (https://forum.x-cart.com/showthread.php?t=70393)

drholmes 11-01-2014 12:59 AM

Limit one coupon per customer
 
Hi,

There is a fundamental problem with the coupon module in X-Cart 5, that it allows customers to use an unlimited amount of coupons. A feature is missing to allow customers to use only one coupon. I've hacked this, but it should be a feature.

Marketing with coupons is about giving codes to websites and blogs for e.g. 10% off. All of these codes end up on www.retailmenot.com, and since X-Cart allows users to enter an unlimited amount of coupons, people can give themselves 10% + 15% + 10% + 20% + 10% + 10% + 15% etc. discounts, until we would literally have to pay them money in order to sell them something.

The few limits are about shopping cart total or times-used, none of which are helpful in controlling that people don't abuse the discounts.

Ideally, this should be a per-coupon option:

(X) Allow coupon to be used with other coupons

-- which can default to being on. When it's off, the cart should be flushed of all existing coupons before a new one is added. That makes it one-per-customer.

This is the default behavior we need -- there is never a situation where allowing multiple coupons is a good thing for us, it's always bad.

So in /XLite/Module/CDev/Coupons/Controller/Customer/Coupon.php at line 122, I've inserted:

Code:

// Delete All Existing
               
                foreach ($this->getCart()->getUsedCoupons() as $usedCoupon) {
                    $this->getCart()->getUsedCoupons()->removeElement($usedCoupon);
                    \XLite\Core\Database::getEM()->remove($usedCoupon);
                }


This flushes the cart of existing coupons.

I think this is not some mere preference for us, there is a fundamental business problem with allowing unlimited coupon usage. Therefore, I think this should be an option in the coupon itself in future updates of the Coupon module.

Best,

Per

tony_sologubov 11-03-2014 04:16 AM

Re: Limit one coupon per customer
 
Hi Per!

Thank you for suggestion! Please report it in ideas.x-cart.com.
Meanwhile, I can help you with a simple mod that will allow customer to input only one coupon code.

If you are ready to go, please create a module according to the article here:
http://kb.x-cart.com/display/XDD/Step+1+-+creating+simplest+module

drholmes 11-03-2014 04:29 AM

Re: Limit one coupon per customer
 
Hi Tony,

I've would love to know how to turn that into a module, since I'm trying to wrap my head around making modules. I did follow that tutorial once, but it crashed the store, and I had to follow the instructions for force redeployment. The new system is complex, I hope you know that :-)

I do strongly believe that this should be in the coupon module itself, since businesses have known for hundreds of years that giving people unlimited coupons leads to every order being for a total of zero dollars.

I did try to post there, but the website kept redirecting me to an X-Cart 4 suggestion form where I had to "re-ask" the question every time I clicked submit, so I gave up.

Best,

Per

tony_sologubov 11-03-2014 04:40 AM

Re: Limit one coupon per customer
 
I am not arguing, this is a great improvement to Coupons functionality, that is why I am asking to report to ideas tracker.

Please try to go to the direct link here: http://ideas.x-cart.com/forums/229428-x-cart-5-x

Let me know if it still does not allow you to post an idea.

As for module creation, if your store crashes again, please create a new thread with the error messages from php_errors.log file of the <X-Cart>/var/log/ folder.

Tony.


All times are GMT -8. The time now is 04:09 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.