I added a module in Ps 1.6. which creates Electronic Invoice. This module adds in the registration form two fields but I'm not able to fetch and update data from the db.
Here below some snippets. First I create the table:
$sqlInstallCod = 'ALTER TABLE ' ._DB_PREFIX_.'customer ADD codice_destinatario VARCHAR(255) DEFAULT NULL';
Db::getInstance()->execute($sqlInstallCod);
$sqlInstallPec = 'ALTER TABLE ' ._DB_PREFIX_.'customer ADD pec VARCHAR(255) DEFAULT NULL';
Db::getInstance()->execute($sqlInstallPec);
Then I try to render data in my registration form by means of the functions below:
public function hookDisplayCustomerAccountForm($params){
$query = 'SELECT codice_destinatario FROM '._DB_PREFIX_.'customer WHERE id_customer=\'' . $params['id_customer']. '\';';
$this->context->smarty->assign('codice_destinatario', '');
$this->context->smarty->assign('pec', '');
return $this->display(__FILE__, 'hookDisplayCustomerAccountForm.tpl');
}
public function hookDisplayCustomerIdentityForm($params){
$query = 'SELECT codice_destinatario FROM '._DB_PREFIX_.'customer WHERE id_customer=\'' . $order_id . '\';';
$this->trace("id_customer",$params['id_customer']);
$query = 'SELECT codice_destinatario FROM >'._DB_PREFIX_.'customer WHERE id_customer=\'' . $params['id_customer']. '\';';
$this->context->smarty->assign('codice_destinatario', '');
$this->context->smarty->assign('pec', '');
return $this->display(__FILE__, 'hookDisplayCustomerAccountForm.tpl');
}
Actually the data is saved in the correct table but neither displayed in front-end nor updated.
I think I need to change also my hookDisplayCustomerAccountForm.tpl file. I tried to do this:
<div class="form-group">
<label for="codice_destinatario">{l s='Codice Destinatario' mod='fattura24'}</label>
<input class="form-control" name="codice_destinatario" type="text" id="codice_destinatario" value="{if isset($smarty.post.codice_destinatario)}{$smarty.post.codice_destinatario|escape:'htmlall':'UTF-8'}{/if}"/>
</div>
<div class="form-group">
<label for="pec">{l s='PEC' mod='fattura24'}</label>
<input class="form-control" name="pec" type="text" id="pec" value="{if isset($smarty.post.pec)}{$smarty.post.pec|escape:'htmlall':'UTF-8'}{/if}"/>
</div>
It doesn't work. Any suggestions? Thanks a lot David