Post by zaidladha » Sat Dec 12, 2015 6:26 am

I need to specify a specific company id length. It needs to follow this pattern "111111ABC" during account registration and checkout. Can anyone provide some insight or help? I am completely lost here.
Last edited by zaidladha on Thu Dec 24, 2015 6:23 am, edited 2 times in total.

Active Member

Posts

Joined
Wed Jun 05, 2013 3:07 pm

Post by zaidladha » Sat Dec 12, 2015 7:00 am

ok,
I think I figured out that I just need this code, but not sure where to put it!!!

my test website is www.canadafishingtackle.com

(utf8_strlen($this->request->post['company_id']) < 8) || (utf8_strlen($this->request->post['company_id']) > 10))

Active Member

Posts

Joined
Wed Jun 05, 2013 3:07 pm

Post by pprmkr » Sat Dec 12, 2015 6:15 pm

Account registration and checkout files:

- catalog/controller/account/register.php
- catalog/controller/checkout/guest.php, register.php and payment_address.php

'company_id' is only validated when set in customer group !

Search for:

Code: Select all

				if ($customer_group['company_id_display'] && $customer_group['company_id_required'] && empty($this->request->post['company_id'])) {
					$json['error']['company_id'] = $this->language->get('error_company_id');
				}
You can use preg_match instead of checking on empty:

Code: Select all

!preg_match ('/^([0-9]{6})([A-Z]{3})$/', $this->request->post['company_id'])
6 digits and 3 characters

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by zaidladha » Sun Dec 13, 2015 12:22 pm

OMG thank you!! Works great, do you know how I can make it accept upper or lower case letters? Currently only uppercase

Active Member

Posts

Joined
Wed Jun 05, 2013 3:07 pm

Post by pprmkr » Sun Dec 13, 2015 2:55 pm

Add lowercase a-z to pattern:

Code: Select all

!preg_match ('/^([0-9]{6})([A-Za-z]{3})$/', $this->request->post['company_id'])

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands
Who is online

Users browsing this forum: No registered users and 8 guests