Jump to content

Missing code in CustomerFormatter.php?


YanGGwp

Recommended Posts

Hello there!

 

Im trying to add new fields into my registration for m for new users in my store, following the next guide:

 

http://prestacraft.com/adding-new-fields-to-the-registration-form-in-prestashop-1-7/#

 

 

But im having some troubles with this due to some code not displayed in my CustomerFormatter.php file...or its just me or there is no such code inside as writed in that guide.

 

Here is the deal:

 

 

Now, extend your Customer model by adding new columns. You can also add there a validation and determine if the field must be required.

 Find:  (THIS DOESNT EXIST)

 
 
public $groupBox;

 Add after: (SO I CANT REALLY COPY PAST THIS)

 
public $my_field;
public $my_field_required;

 Find: (THIS DOESNT EXIST)

 
'table' => 'customer',
'primary' => 'id_customer',
'fields' => array(

 Add after: (SO I CANT REALLY COPY PAST THIS)

 
'my_field' => array('type' => self::TYPE_STRING),
'my_field_required' => array('type' => self::TYPE_STRING, 'required' => true),

 

I've created 4 new columns in my ps_customer table.

 

which are:

ALTER TABLE ggwplayc_customer ADD COLUMN my_tlf_required VARCHAR(250);
ALTER TABLE ggwplayc_customer ADD COLUMN my_dif_required VARCHAR(250);
ALTER TABLE ggwplayc_customer ADD COLUMN my_dir_required VARCHAR(250);
ALTER TABLE ggwplayc_customer ADD COLUMN my_cps_required VARCHAR(250);

After that Ive made and added next code as stated in the guide.


$format['my_tlf_required'] = (new FormField)
    ->setName('my_tlf_required')
    ->setLabel(
        $this->translator->trans(
            'Telefono', [], 'Shop.Forms.Labels'
        )
    )
	->setRequired(true)
;
 $format['my_dif_required'] = (new FormField)
    ->setName('my_dif_required')
    ->setLabel(
        $this->translator->trans(
            'CIF/NIE/DIF/PASAPORTE', [], 'Shop.Forms.Labels'
        )
    )
    ->setRequired(true)
;
$format['my_dir_required'] = (new FormField)
    ->setName('my_dir_required')
    ->setLabel(
        $this->translator->trans(
            'Direccion', [], 'Shop.Forms.Labels'
        )
    )
    ->setRequired(true)
;
$format['my_cps_required'] = (new FormField)
    ->setName('my_cps_required')
    ->setLabel(
        $this->translator->trans(
            'Codigo Postal', [], 'Shop.Forms.Labels'
        )
    )
    ->setRequired(true)
;

So yeah the problem is i cant find the code he is asking me to find lol in that specific .php file :((( 

 

any ideas?

CustomerFormatter.php

Edited by YanGGwp (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...