Author Topic: Optional field  (Read 3591 times)

Offline juancot

  • Newbie
  • *
  • Posts: 3
  • Karma: +1/-0
    • View Profile
Optional field
« on: August 03, 2020, 07:14:59 PM »
Hi.
I am using AvanteCart for the first time and here in my country we do not use the zip code, I need it to be an optional field, how can I do this in AvanteCart version 1.2.16?
Ir can I make my own customer registration form?
Thank you.

Offline dvagner

  • Core/UI Developer
  • Jr. Member
  • **
  • Posts: 73
  • Karma: +28/-1
    • View Profile
Re: Optional field
« Reply #1 on: August 04, 2020, 01:47:15 AM »
Hi
You can use hook
for example:

Code: [Select]
public function onModelAccountCustomer_ValidateData()
{
  $that = &$this->baseObject;
  if (isset($that->error['postcode'])) {
unset($that->error['postcode']);
}
}

Offline juancot

  • Newbie
  • *
  • Posts: 3
  • Karma: +1/-0
    • View Profile
Re: Optional field
« Reply #2 on: August 07, 2020, 09:52:28 PM »
Thanks for your help, but where do I have to put this?
I don't know much about programming.

Offline juancot

  • Newbie
  • *
  • Posts: 3
  • Karma: +1/-0
    • View Profile
Re: Optional field
« Reply #3 on: August 12, 2020, 12:11:11 AM »
I found the solution to this and share it:
find the create.php file in
storefront \ controller \ pages \ account \
and change the following code:

$this->data['form']['fields']['address']['postcode'] = $form->getFieldHtml(
            array(
                'type'     => 'input',
                'name'     => 'postcode',
                'value'    => $this->request->post['postcode'],
                'required' => ture,
            ));

Change it for:

$this->data['form']['fields']['address']['postcode'] = $form->getFieldHtml(
            array(
                'type'     => 'input',
                'name'     => 'postcode',
                'value'    => $this->request->post['postcode'],
                'required' => false,
            ));

A friend helped me  8) and I share it with you, I suppose it can be used for something more than the zip code. ;)

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Optional field
« Reply #4 on: August 12, 2020, 07:57:40 AM »
Thank you Juancot for sharing this solution.
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

 

Powered by SMFPacks Social Login Mod