Page 1 of 1

Coupon Character Length

Posted: Fri Sep 17, 2010 8:38 am
by YarniaPDX
Is there any way to change the parameters of the coupon codes? I am switching over to OpenCart from Prestashop, and have a lot of coupons floating around out there that are more than 10 characters long, but as I'm inputting them into OpenCart I'm getting the error message that coupon codes need to be between 3 and 10 characters long. This is a pretty big problem, as these coupons won't expire for awhile and I need to be able to still honor them. Any place I can go in and tweak the maximum character allowance?

Thanks!!

Re: Coupon Character Length

Posted: Fri Sep 17, 2010 7:39 pm
by mystifier
The field Coupon.Code is defined in the database as Varchar(10), so you will need to increase the size.

In admin/language/sale/coupon.php, you need to change:

Code: Select all

$_['error_code']          = 'Code must be between 3 and 10 characters!';
...to suit your new size.

In admin/controller/sale/coupon.php, you need to change:

Code: Select all

if ((strlen(utf8_decode($this->request->post['code'])) < 3) || (strlen(utf8_decode($this->request->post['code'])) > 10)) {
...to validate your new size.

That's it!

Re: Coupon Character Length

Posted: Mon Sep 20, 2010 5:34 am
by YarniaPDX
Fantastic, that totally worked. Thanks!

Re: Coupon Character Length

Posted: Sun Feb 27, 2011 3:04 am
by chocomarker1
totally works - NOT.

i did these changes, and it lets me finally save without making a ruckus.

however, upon checking WHAT opencart saved, is actually the first 10 digits only of the code.

so the code changes in these php files actually dont make opencart save actual more digits but rather just cuts off things after 10 characters. what is the real solution for this? what else needs to be edited for opencart to swallow more than 10 digits?

Re: Coupon Character Length

Posted: Sat Jun 11, 2011 4:08 am
by yiyinlah
I need this solution too please!

Re: Coupon Character Length

Posted: Sun Jul 24, 2011 4:15 am
by s3d
its works fine
if your going to whine, then make sure you have more than a ounce of braincells and some gratitude for those who are helping you

Follow the above, and of course, edit the table PREFIX_coupon - making the varchar amount of the field 'code' more suitable (e.g. more than 10)

Regards

Matt

Re: Coupon Character Length

Posted: Sun Jul 24, 2011 4:50 pm
by yiyinlah
How do I edit the table PREFIX_Coupon?

This is very urgent though, please help s3d.

Thank you so much! :)

Btw, this is for v.1.4.9.5 right?

Re: Coupon Character Length

Posted: Wed Nov 16, 2011 8:56 am
by Seuldieu
The above solution works fine.

You need to go into the PHPAdmin of the MySQL database your Opencart installation is using, click the Coupon table and edit the field "Code" (which will should show varchar(10) as the type) and change it to your desired length.

Don't forget to change your error message inside Admin/Language/English/Sale/Coupon.php !

Re: Coupon Character Length

Posted: Thu Nov 17, 2011 4:25 pm
by yiyinlah
This works for all versions?
I'm using 1.5.1.3 & 1.4.9.5.

Re: Coupon Character Length

Posted: Wed Feb 01, 2012 1:01 am
by yiyinlah
Yeah, it works on 1.5.1.3 :)
Jus remember to edit the PHPmyadmin side, under _coupon table.

Re: Coupon Character Length

Posted: Wed Apr 04, 2012 11:36 am
by naderonics
Hi all,

Thank you for your provided solution. It works but I still have a problem.
I'm on OpenCart 1.5.1.3
I changed the Varchar on the database.
I also changed the php lines on both mentioned pages.

And it works... It creates the coupon with the new number of characters and it works also on the front end. But every time I try to create a coupon (insert coupon) in the backend it generates the error below when I click save.

Warning: Cannot modify header information - headers already sent by (output started at /home/thecashb/public_html/naderonics/OnlineStore/admin/language/english/sale/coupon.php:87) in /home/thecashb/public_html/naderonics/OnlineStore/system/engine/controller.php on line 28Warning: Cannot modify header information - headers already sent by (output started at /home/thecashb/public_html/naderonics/OnlineStore/admin/language/english/sale/coupon.php:87) in /home/thecashb/public_html/naderonics/OnlineStore/system/engine/controller.php on line 29

And although it generates this error, it still works creating the coupon. But obviously it doesn't take me back to the coupon page and say successfully created or anything!

Please please help!!

Re: Coupon Character Length

Posted: Thu Jun 14, 2012 6:40 am
by hudbarnett
Hi there, i too have been faced with Voucher codes which are over 10 characters in length. I followed the suggested process and it works but I do have a question for someone.

Before making the changes to the database and files I was running vqmod so that I could add multiple codes at once. This has now stopped working and I believe that there must be something else that I’d need to change in order to use the vqmod with the extra characters.

Has anyone else come across this?

Re: Coupon Character Length

Posted: Fri Jun 15, 2012 3:13 am
by hudbarnett
I managed to fix this after some testing. If you are using the vqmod for Batch Coupon Codes there is a file called vqmod_batch_coupn.xml there is 3 sections that you need to change the characters from 10 to for example 25. Once i did this i was able to upload longer voucher codes up to 25 characters and multiple amounts.

So far its working for me.

Re: Coupon Character Length

Posted: Thu Jun 28, 2012 5:47 pm
by abhishekdaaga
Initially I couldn't do it as my admin name was different then in language there was no file so I had to go into language/english then file. Also in Mysql DB changed it.
But finally made it. Thank You mystifier a ton for the way out :)

Re: Coupon Character Length

Posted: Mon Feb 11, 2013 7:48 pm
by yiyinlah
Again it works for 1.5.4.1! :)
Thank you mystifier!

Re: Coupon Character Length

Posted: Wed Jun 05, 2013 3:59 pm
by cookie321
Thank you so much, this helped hugely & really easy to follow! :)

Re: Coupon Character Length

Posted: Fri Mar 21, 2014 12:27 am
by YarniaPDX
So, I'm having this same problem again, even though the code I altered is still intact -- that line of coupon.php reads

if ((utf8_strlen($this->request->post['code']) < 3) || (utf8_strlen($this->request->post['code']) > 25)) {
$this->error['code'] = $this->language->get('error_code');

Yet when I enter a coupon whose coupon code is longer than 10 characters, the system truncates it to only 10 characters. I need to be able to input longer coupon codes so they match my gift card codes; do I need to be altering the code somewhere else as well?

Re: Coupon Character Length

Posted: Mon Mar 24, 2014 4:51 pm
by jens_b
YarniaPDX wrote:So, I'm having this same problem again, even though the code I altered is still intact -- that line of coupon.php reads

if ((utf8_strlen($this->request->post['code']) < 3) || (utf8_strlen($this->request->post['code']) > 25)) {
$this->error['code'] = $this->language->get('error_code');

Yet when I enter a coupon whose coupon code is longer than 10 characters, the system truncates it to only 10 characters. I need to be able to input longer coupon codes so they match my gift card codes; do I need to be altering the code somewhere else as well?
Scroll up to post by "s3d » Sat Jul 23, 2011 3:15 pm", there is your answer ;)

Re: Coupon Character Length

Posted: Wed Nov 19, 2014 3:18 pm
by smbehm
Followed This for OC 1.5.6
The field Coupon.Code is defined in the database as Varchar(10), so you will need to increase the size.

In admin/language/sale/coupon.php, you need to change:
CODE: SELECT ALL
$_['error_code'] = 'Code must be between 3 and 10 characters!';

...to suit your new size.

In admin/controller/sale/coupon.php, you need to change:
CODE: SELECT ALL
if ((strlen(utf8_decode($this->request->post['code'])) < 3) || (strlen(utf8_decode($this->request->post['code'])) > 10)) {

...to validate your new size.

That's it!

And This
Follow the above, and of course, edit the table PREFIX_coupon - making the varchar amount of the field 'code' more suitable (e.g. more than 10)
I found the setting through my PHP Admin>OC_COUPON>COLUMNS>CODE

I changed the length to 15


Thanks for this thread

Re: Coupon Character Length

Posted: Sat Jun 17, 2017 2:24 am
by Ana do Kastelo
s3d wrote:
Sun Jul 24, 2011 4:15 am
its works fine
if your going to whine, then make sure you have more than a ounce of braincells and some gratitude for those who are helping you

Follow the above, and of course, edit the table PREFIX_coupon - making the varchar amount of the field 'code' more suitable (e.g. more than 10)

Regards

Matt
Hi. I was google searching for this issue. I'm using 2.2.0.0. and need to expand the limit. Where is this PREFIX_coupon setting? I've edited both php and language file and it's still giving me the same max 10 feedback. Maybe the server is slow and will turn out fine in a few hours, it's not the first time changes take time. Anyway, where is that table thing? Please.

Thank you for your support,

Ana.