Page 1 of 1

Coupon code case sensitivity

Posted: Thu Jun 09, 2011 6:14 pm
by traceofwind
Hi,

Could any one help me? I would like to accept coupon codes without checking case, so that for example 'Eu15', 'eu15' and 'EU15' would all be accepted as 'EU15' coupon code.

Presently (OpenCart 1.4.9.3) coupon codes are subject to case verification. How do I bypass this?

Thanks in advance,

Gary

Re: Coupon code case sensitivity

Posted: Fri Oct 07, 2011 6:12 pm
by fourgood
*push*

Re: Coupon code case sensitivity

Posted: Fri Oct 07, 2011 9:36 pm
by uksitebuilder
Try the following:

edit: catalog/model/checkout/coupon.php

find

Code: Select all

		$coupon_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "coupon c LEFT JOIN " . DB_PREFIX . "coupon_description cd ON (c.coupon_id = cd.coupon_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c.code = '" . $this->db->escape($coupon) . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) AND c.status = '1'");
change to

Code: Select all

		$coupon_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "coupon c LEFT JOIN " . DB_PREFIX . "coupon_description cd ON (c.coupon_id = cd.coupon_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND LCASE(c.code) = '" . $this->db->escape(strtolower($coupon)) . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) AND c.status = '1'");

Re: Coupon code case sensitivity

Posted: Sat Oct 08, 2011 7:33 pm
by i2Paq

Re: Coupon code case sensitivity

Posted: Wed Oct 12, 2011 5:23 pm
by fourgood
@uksitebuilder this works just great!

Thanks!

Re: Coupon code case sensitivity

Posted: Wed Oct 12, 2011 5:28 pm
by uksitebuilder
Allthough I guess this could be classed as a bug, I doubt anyone would create two vouchers in this way

Re: Coupon code case sensitivity

Posted: Wed Oct 12, 2011 7:25 pm
by Qphoria
This isn't a bug, it is a feature.
Coupon codes should always be case sensitive IMO
But an option for case-sensitivity can be added .

Re: Coupon code case sensitivity

Posted: Wed Oct 12, 2011 10:14 pm
by i2Paq
Qphoria wrote:
This isn't a bug, it is a feature.
Coupon codes should always be case sensitive IMO
But an option for case-sensitivity can be added .
OK, an option to set the case sensitive would do :)

Re: Coupon code case sensitivity

Posted: Tue Nov 22, 2011 4:08 am
by devrm
For 1.5.1, to make coupon codes case blind by making both user input and db output uppercase, perform the following:
In (catalog\model\checkout\coupon.php) at approx line 6, make the following highlighted changes:

Highlights:
$coupon_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "coupon WHERE UCASE(code) = '" . $this->db->escape(strtoupper($code)) . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) AND status = '1'");

Code:

Code: Select all

$coupon_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "coupon WHERE [b][highlight]UCASE(code)[/highlight] [/b]= '" . $this->db->escape([b][highlight]strtoupper($code)[/highlight][/b]) . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) AND status = '1'");
Although a worthwhile feature, sometimes customer usability trumps coding prowess.

Re: Coupon code case sensitivity

Posted: Tue Dec 18, 2012 2:24 pm
by MrSmileyJr
has this been updated in the latest version?