Opencart 2,3,0,2, Journal 3 Theme
i want to do a validation for telephone in one page check out. customer can register via new customer or during onepage checkout. in Journal theme which telephone is marked as required. for new customer i used the code below and works perfect, checks the telephone number is digit and contains only numbers.
if (
(utf8_strlen($this->request->post['telephone']) < 9) ||
(utf8_strlen($this->request->post['telephone']) > 11) ||
preg_match('/[^\d]/is', $this->request->post['telephone'])
) {
$this->error['telephone'] = $this->language->get('error_telephone');
in onepage checkout, it does not validate the number same code below.
if (
(utf8_strlen(trim($this->request->post['telephone'])) < 1) ||
(utf8_strlen(trim($this->request->post['telephone'])) > 32)||
preg_match('/[^\d]/is', $this->request->post['telephone'])
) {
$json['error']['telephone'] = $this->language->get('error_telephone');
}
how can i do a validation with the variable above, what could be the reason? do i control tpl files?
Opencart 2,3,0,2, Journal 3 Theme
i want to do a validation for telephone in one page check out. customer can register via new customer or during onepage checkout. in Journal theme which telephone is marked as required. for new customer i used the code below and works perfect, checks the telephone number is digit and contains only numbers.
if (
(utf8_strlen($this->request->post['telephone']) < 9) ||
(utf8_strlen($this->request->post['telephone']) > 11) ||
preg_match('/[^\d]/is', $this->request->post['telephone'])
) {
$this->error['telephone'] = $this->language->get('error_telephone');
in onepage checkout, it does not validate the number same code below.
if (
(utf8_strlen(trim($this->request->post['telephone'])) < 1) ||
(utf8_strlen(trim($this->request->post['telephone'])) > 32)||
preg_match('/[^\d]/is', $this->request->post['telephone'])
) {
$json['error']['telephone'] = $this->language->get('error_telephone');
}
how can i do a validation with the variable above, what could be the reason? do i control tpl files?
Share Improve this question edited Mar 7 at 14:41 snk asked Mar 6 at 4:39 snksnk 152 bronze badges 6- Can you clarify the problem further? You've tagged this with MySQL and journal - how are these techniques related? – Nico Haase Commented Mar 6 at 11:01
- yes of course, recomended tag was php, so i added to mysql also. Opencart has to register options, account/register and checkout/register. mysql telephone cell is limited to 16 characters in customer table. I can validate telephone number in account/register without problem. but i can not use the same codes for validation in checkout/register (non numeric character and length of 10 digits). so customer can add non numeric characters to telephone cell by passing validation. to use preg_match, want to validate (non numeric character and length of 10 digits) in checkout/register – snk Commented Mar 6 at 11:30
- Please add all clarification to your question by editing it. If this is not related to MySQL or "journal", please also remove these tags – Nico Haase Commented Mar 6 at 15:04
- ok, i removed mysql, Opencart Journal Theme is correct. – snk Commented Mar 7 at 5:19
- You still haven't explained anything about the problem itself. "(...) is not solved in this way" - what does that mean? – Nico Haase Commented Mar 7 at 10:43
1 Answer
Reset to default 0if ($this->journal3->settings->get('quickCheckoutAccountTelephoneField') === 'required') {
$telephone = Arr::get($this->request->post, 'order_data.telephone');
if ((utf8_strlen($telephone) == 10 ) || preg_match('/[^\d]/is', $telephone)) {
$error['telephone'] = $this->language->get('error_telephone');
}
}
In opencart 2,3,0,2, Journal theme has another register.php
, this works for validation for telephone.