Post by traceofwind » Thu Jun 09, 2011 6:14 pm

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

New member

Posts

Joined
Fri Jul 02, 2010 6:37 am

Post by fourgood » Fri Oct 07, 2011 6:12 pm

*push*

Active Member

Posts

Joined
Wed Oct 20, 2010 9:49 pm

Post by uksitebuilder » Fri Oct 07, 2011 9:36 pm

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'");

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by i2Paq » Sat Oct 08, 2011 7:33 pm


Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by fourgood » Wed Oct 12, 2011 5:23 pm

@uksitebuilder this works just great!

Thanks!

Active Member

Posts

Joined
Wed Oct 20, 2010 9:49 pm

Post by uksitebuilder » Wed Oct 12, 2011 5:28 pm

Allthough I guess this could be classed as a bug, I doubt anyone would create two vouchers in this way

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Qphoria » Wed Oct 12, 2011 7:25 pm

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 .

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by i2Paq » Wed Oct 12, 2011 10:14 pm

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 :)

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by devrm » Tue Nov 22, 2011 4:08 am

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.

Newbie

Posts

Joined
Tue Nov 02, 2010 3:30 am

Post by MrSmileyJr » Tue Dec 18, 2012 2:24 pm

has this been updated in the latest version?

Never lose data again! Use Dropbox - DO THIS BEFORE YOU SIGNUP for Extra Space!!
http://db.tt/inKP3mv Signing up via this link gives you a bonus of 256 MB
More Bonuses: http://www.dropbox.com/free .5 GB
http://www.dropbox.com/edu = double your bonus referrals by giving an edu address.
Total ~ 3gb


New member

Posts

Joined
Fri Mar 11, 2011 5:07 am
Who is online

Users browsing this forum: No registered users and 59 guests