0% found this document useful (0 votes)
484 views4 pages

Add Custom Fields For Prestashop Checkout

This document provides instructions for adding a custom referral code field to the customer registration form in Prestashop 1.5. It involves modifying templates, controllers and classes to add the field to the registration page and database, retrieve the value, and display it on the admin customer list. Files that need to be edited include authentication.tpl, AuthController.php, Customer.php, and AdminCustomersController.php. Database alterations are also required to add the referral code column to the customer table.

Uploaded by

Lucian Boro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
484 views4 pages

Add Custom Fields For Prestashop Checkout

This document provides instructions for adding a custom referral code field to the customer registration form in Prestashop 1.5. It involves modifying templates, controllers and classes to add the field to the registration page and database, retrieve the value, and display it on the admin customer list. Files that need to be edited include authentication.tpl, AuthController.php, Customer.php, and AdminCustomersController.php. Database alterations are also required to add the referral code column to the customer table.

Uploaded by

Lucian Boro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

http://www.bitsandchips.it/forum/viewtopic.php?

f=11&t=4884

Prestashop 1.5: add custom field in Customer Registration


da dino lun mag 13, 2013 3:10 pm
This is a guide on howto add a custom field in the customer registration form in Prestashop 1.5.
Modifications is for your reference: please take into account that your Prestashop installation
may be different from mine because of a different template or minor software revision. In this
modification I was unable to use the override files because some of them are encrypted (used by
some 3rd parties modules) so I have changed base files.
Warning: made a backup of the file prior to modify them!
File "themes/NOME_DEL_TEMA/authentication.tpl "
Add this lines in the point where you want:
Codice: Seleziona tutto
<p class="text">
<label for="referralcode">{l s='Referral code'}</label>
<input name="referralcode" type="text" class="text" id="referralcode" />
</p>

Si in order-opc-new-account.tpl se pune codul, ca sa apara campul in cos 'comanda rapida'


If you are using translation file, available on the folder "themes/NOME_DEL_TEMA/lang", add
following two lines:
Codice: Seleziona tutto
$_LANG['authentication-create-account_1b4033814553ad8ffb709e3b5cc6ee2c'] =
'INSERIRE_QUI_LA_TRADUZIONE';
$_LANG['authentication_1b4033814553ad8ffb709e3b5cc6ee2c'] =
'INSERIRE_QUI_LA_TRADUZIONE';
Warning: probably it's necessary to repeat the same code in other section of the file (depending
on template).
File "controllers/front/AuthController.php"
About line 390, find the code:
Codice: Seleziona tutto

// Preparing customer
$customer = new Customer();
$lastnameAddress = Tools::getValue('lastname');
$firstnameAddress = Tools::getValue('firstname');

After, add:
Codice: Seleziona tutto
$referralCode = Tools::getValue('referralcode');

About line 430, find the code:


Codice: Seleziona tutto

$customer->birthday = (empty($_POST['years']) ? '' : (int)


$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']);
if (!Validate::isBirthDate($customer->birthday))
$this->errors[] = Tools::displayError('Invalid date of birth.');

After, add:
Codice: Seleziona tutto

$customer->referralcode = $referralCode;

Linea 520 (circa), cercare il codice:


Codice: Seleziona tutto
$customer->birthday = (empty($_POST['years']) ? '' : (int)
$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']);
if (!Validate::isBirthDate($customer->birthday))
$this->errors[] = Tools::displayError('Invalid date of birth');

Di seguito aggiungere:
Codice: Seleziona tutto
$customer->referralcode = $referralCode;

About line 650, find the code:


Codice: Seleziona tutto

$this->context->customer = $customer;
$this->context->smarty->assign('confirmation', 1);
$this->context->cookie->id_customer = (int)$customer->id;

After, add:
Codice: Seleziona tutto
$this->context->cookie->customer_referralcode = $customer->referralcode;

File "classes/Customer.php"
About line 30, find the code:
Codice: Seleziona tutto
public $id;

After, add:
Codice: Seleziona tutto
/** @var string Referralcode */
public $referralCode;

in classes/Customer.php
around line 160
public static $definition = array(
...
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true,
'size' => 32),
Below this line, add this line
'ci' => array('type' => self::TYPE_STRING, 'required' => true, 'validate' => 'isGenericName',
'size' => 9),

In order to show the field in the customer list within the Administration section, please modify
the file "controllers/admin/AdminCustomersController.php"
About line 143, find the code:
Codice: Seleziona tutto
'connect' => array(
'title' => $this->l('Last visit'),
'width' => 100,
'type' => 'datetime',

'search' => false,


'havingFilter' => true
)

);

Replace it with the following:


Codice: Seleziona tutto
'connect' => array(
'title' => $this->l('Last visit'),
'width' => 100,
'type' => 'datetime',
'search' => false,
'havingFilter' => true
),
'referralcode' => array(
'title' => $this->l('Referral code'),
'width' => 'auto',
'search' => true
)
);

Ca sa putem edita clientii din admin, si sa apara si campul obligatoriu serie si nr. buletin:
controllers/admin -> AdminCustomersController.php
line 308 add:
array(
'type' => 'text',
'label' => $this->l('Serie si Numar Buletin:'),
'name' => 'ci',
'size' => 9,
'required' => true
),
Alter the database (if you are using the table suffix "ps" the table is `ps_customer`):
Codice: Seleziona tutto

ALTER TABLE `ps_customer`


ADD `referralcode` VARCHAR( 100 )

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy