Jump to content

[SOLVED]Add extra number to contact module


Recommended Posts

  • 11 months later...

Hi Adelnaser,

Hope you mean the module with the woman telephoning: (blockcontact):

 

here we go:

 

Edit file: /modules/blockcontact/bockcontact.php: (N.B. Backup file first!)

 

Add red code: (N.B. Easily done. Mostly copy code piece of original phone number( number 1) and add a '2' behind it)

 

public function install()

{

return parent::install()

&& Configuration::updateValue('blockcontact_telnumber', '')

&& Configuration::updateValue('blockcontact_telnumber2', '')

&& Configuration::updateValue('blockcontact_email', '')

&& $this->registerHook('displayRightColumn')

&& $this->registerHook('displayHeader');

}

 

public function uninstall()

{

// Delete configuration

return Configuration::deleteByName('blockcontact_telnumber') && Configuration::deleteByName('blockcontact_telnumber2') && Configuration::deleteByName('blockcontact_email') && parent::uninstall();

}

 

 

 

public function getContent()

{

$html = '';

// If we try to update the settings

if (Tools::isSubmit('submitModule'))

{

Configuration::updateValue('blockcontact_telnumber', Tools::getValue('telnumber'));

Configuration::updateValue('blockcontact_telnumber2', Tools::getValue('telnumber2'));

Configuration::updateValue('blockcontact_email', Tools::getValue('email'));

$this->_clearCache('blockcontact.tpl');

$html .= '<div class="conf confirm">'.$this->l('Configuration updated').'</div>';

}

 

$html .= '

<h2>'.$this->displayName.'</h2>

<form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post">

<fieldset>

<label for="telnumber">'.$this->l('Telephone number:').'</label>

<input type="text" id="telnumber" name="telnumber" value="'.((Configuration::get('blockcontact_telnumber') != '') ? Tools::safeOutput(Configuration::get('blockcontact_telnumber')) : '').'" />

<div class="clear"> </div>

<label for="telnumber2">'.$this->l('2nd telephone number:').'</label>

<input type="text" id="telnumber2" name="telnumber2" value="'.((Configuration::get('blockcontact_telnumber2') != '') ? Tools::safeOutput(Configuration::get('blockcontact_telnumber2')) : '').'" />

<div class="clear"> </div>

<label for="email">'.$this->l('Email').'</label>

<input type="text" id="email" name="email" value="'.((Configuration::get('blockcontact_email') != '') ? Tools::safeOutput(Configuration::get('blockcontact_email')) : '').'" />

<div class="clear"> </div>

<div class="margin-form">

<input type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center>

</div>

</fieldset>

</form>';

 

return $html;

}

 

 

 

public function hookDisplayRightColumn()

{

global $smarty;

if (!$this->isCached('blockcontact.tpl', $this->getCacheId()))

$smarty->assign(array(

'telnumber' => Configuration::get('blockcontact_telnumber'),

'telnumber2' => Configuration::get('blockcontact_telnumber2'),

'email' => Configuration::get('blockcontact_email')

));

return $this->display(__FILE__, 'blockcontact.tpl', $this->getCacheId());

}

 

---------------------------------------------------------------------------------

 

Then edit file: /themes/<your theme folder>/modules/blockcontact/blockcontact.tpl. (N.B. If you don't have this file, COPY it to this place from /modules/blockcontact/blockcontact.tpl) (N.B. Backup file first!)

 

 

Add red code: (N.B. Easily done again. Mostly copy code piece of original phone number( number 1) and add a '2' behind it)

 

<div id="contact_block" class="block">

<p class="title_block">{l s='Contact us' mod='blockcontact'}</p>

<div class="block_content clearfix">

<p>{l s='Our hotline is available 24/7' mod='blockcontact'}</p>

{if $telnumber != ''}<p class="tel"><span class="label">{l s='Phone:' mod='blockcontact'}</span>{$telnumber|escape:'htmlall':'UTF-8'}</p>{/if}

{if $telnumber2 != ''}<p class="tel"><span class="label">{l s='2nd phone:' mod='blockcontact'}</span>{$telnumber2|escape:'htmlall':'UTF-8'}</p>{/if}

{if $email != ''}<a href="mailto:{$email|escape:'htmlall':'UTF-8'}">{l s='Contact our hotline' mod='blockcontact'}</a>{/if}

</div>

</div>

 

(N.B. As you can see, we DON'T change the code piece

<p class="tel">.

We just reuse the tel class css code)

 

------------------------------------------------------------------------------------------------

 

Finally, the lady will be a little too low when adding a 2nd phone number, so we move the background picture up a little.

Edit file: modules/blockcontact/blockcontact.css (N.B. Backup file first!)

Add red code:

 

 

#contact_block .block_content {

padding:10px 0 15px 0;

background: url(images/block_contact_bg.jpg) no-repeat left bottom transparent;

background-position-y: 60px;

}

 

save all files and go to modules->modules

- filter on "Front office modules" on the left to easily find the block contact module.

- Click 'Reset' link. The module will be reinstalled, adding the 2nd tel number field to the configuration screen.

- Click 'configuration' link and add both tel numbers.

- Click Update values to store the new phone number.

 

- Go to your shop and reload the front page. See if it works

(if no change, go to Back office->Advanced parameters->Performance and change the 'Template cache' to "Recompile templates when the files have been updated" and turn cache to OFF. then reload shop page again. (When everything shows ok, turn cache to ON again!)

 

Hope this does the trick.

 

pascal

Link to comment
Share on other sites

Hi guys,

 

First of all GOD BLESS YOU!!! I've been 6 hours on this thing and finally a solution!!!

 

@ vekia: I already tried that way but I couldn't add a logo to the numbers, I have 3 phone networks in my country and want to add a logo in front of each number, dont know why but I couldnt add one, it just didnt show.

 

@ Pascal: You`re a life saver!!!! Everything worked fine BUT, it seems something is wrong after I press Update Settings... The 3rd field numer (I added 2 more fields) goes at top in the 1st number position and thats the only number that shows on the block.. what did I miss?

 

Also, for me to add 3 logo's I added p.tel2 and p.tel3 sections in the css file and assigned telnumber2 to p.tel2 and so on.. I think this is ok and didnt mess anything up :)

 

Can you please tell me what to modify for the savings to take effect?

 

Screens attached

1zgz2vm.jpg

14bhusp.jpg

ztdh84.jpg

Link to comment
Share on other sites

Looks like you missed some change from telnumber to telnumber2 or telnumber3

So please double/triple check if you added all changes correctly.

 

 

To give some reference/comparison option for three phone numbers, here My files in total, adjusted for three phone numbers (modified files of Prestashop Version 1.5.4.1):

 

 

FILE: /modules/blockcontact/blockcontact.php:

 

<?php

/*

* 2007-2013 PrestaShop

*

* NOTICE OF LICENSE

*

* This source file is subject to the Academic Free License (AFL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/afl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to [email protected] so we can send you a copy immediately.

*

* DISCLAIMER

*

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <[email protected]>

* @copyright 2007-2013 PrestaShop SA

* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*/

 

if (!defined('_CAN_LOAD_FILES_'))

exit;

 

class Blockcontact extends Module

{

public function __construct()

{

$this->name = 'blockcontact';

$this->tab = 'front_office_features';

$this->version = '1.0';

 

parent::__construct();

 

$this->displayName = $this->l('Contact Block');

$this->description = $this->l('Allows you to add additional information about your store\'s customer service.');

}

 

public function install()

{

return parent::install()

&& Configuration::updateValue('blockcontact_telnumber', '')

&& Configuration::updateValue('blockcontact_telnumber2', '')

&& Configuration::updateValue('blockcontact_telnumber3', '')

&& Configuration::updateValue('blockcontact_email', '')

&& $this->registerHook('displayRightColumn')

&& $this->registerHook('displayHeader');

}

 

public function uninstall()

{

// Delete configuration

return Configuration::deleteByName('blockcontact_telnumber') && Configuration::deleteByName('blockcontact_telnumber2') && Configuration::deleteByName('blockcontact_telnumber3') && Configuration::deleteByName('blockcontact_email') && parent::uninstall();

}

 

public function getContent()

{

$html = '';

// If we try to update the settings

if (Tools::isSubmit('submitModule'))

{

Configuration::updateValue('blockcontact_telnumber', Tools::getValue('telnumber'));

Configuration::updateValue('blockcontact_telnumber2', Tools::getValue('telnumber2'));

Configuration::updateValue('blockcontact_telnumber3', Tools::getValue('telnumber3'));

Configuration::updateValue('blockcontact_email', Tools::getValue('email'));

$this->_clearCache('blockcontact.tpl');

$html .= '<div class="conf confirm">'.$this->l('Configuration updated').'</div>';

}

 

$html .= '

<h2>'.$this->displayName.'</h2>

<form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post">

<fieldset>

<label for="telnumber">'.$this->l('Telephone number:').'</label>

<input type="text" id="telnumber" name="telnumber" value="'.((Configuration::get('blockcontact_telnumber') != '') ? Tools::safeOutput(Configuration::get('blockcontact_telnumber')) : '').'" />

<div class="clear"> </div>

<label for="telnumber2">'.$this->l('2nd telephone number:').'</label>

<input type="text" id="telnumber2" name="telnumber2" value="'.((Configuration::get('blockcontact_telnumber2') != '') ? Tools::safeOutput(Configuration::get('blockcontact_telnumber2')) : '').'" />

<div class="clear"> </div>

<label for="telnumber3">'.$this->l('3rd telephone number:').'</label>

<input type="text" id="telnumber3" name="telnumber3" value="'.((Configuration::get('blockcontact_telnumber3') != '') ? Tools::safeOutput(Configuration::get('blockcontact_telnumber3')) : '').'" />

<div class="clear"> </div>

<label for="email">'.$this->l('Email').'</label>

<input type="text" id="email" name="email" value="'.((Configuration::get('blockcontact_email') != '') ? Tools::safeOutput(Configuration::get('blockcontact_email')) : '').'" />

<div class="clear"> </div>

<div class="margin-form">

<input type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center>

</div>

</fieldset>

</form>';

 

return $html;

}

 

public function hookDisplayHeader()

{

$this->context->controller->addCSS(($this->_path).'blockcontact.css', 'all');

}

 

public function hookDisplayRightColumn()

{

global $smarty;

if (!$this->isCached('blockcontact.tpl', $this->getCacheId()))

$smarty->assign(array(

'telnumber' => Configuration::get('blockcontact_telnumber'),

'telnumber2' => Configuration::get('blockcontact_telnumber2'),

'telnumber3' => Configuration::get('blockcontact_telnumber3'),

'email' => Configuration::get('blockcontact_email')

));

return $this->display(__FILE__, 'blockcontact.tpl', $this->getCacheId());

}

 

public function hookDisplayLeftColumn()

{

return $this->hookDisplayRightColumn();

}

}

?>

 

 

FILE: themes/<YOUR THEME FOLDER>/modules/blockcontact/blockcontact.tpl

 

{*

* 2007-2013 PrestaShop

*

* NOTICE OF LICENSE

*

* This source file is subject to the Academic Free License (AFL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/afl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to [email protected] so we can send you a copy immediately.

*

* DISCLAIMER

*

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <[email protected]>

* @copyright 2007-2013 PrestaShop SA

* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*}

 

<div id="contact_block" class="block">

<p class="title_block">{l s='Contact us' mod='blockcontact'}</p>

<div class="block_content clearfix">

<p>{l s='Our hotline is available 24/7' mod='blockcontact'}</p>

{if $telnumber != ''}<p class="tel"><span class="label">{l s='Phone:' mod='blockcontact'}</span>{$telnumber|escape:'htmlall':'UTF-8'}</p>{/if}

{if $telnumber2 != ''}<p class="tel"><span class="label">{l s='2nd phone:' mod='blockcontact'}</span>{$telnumber2|escape:'htmlall':'UTF-8'}</p>{/if}

{if $telnumber3 != ''}<p class="tel"><span class="label">{l s='3rd phone:' mod='blockcontact'}</span>{$telnumber3|escape:'htmlall':'UTF-8'}</p>{/if}

{if $email != ''}<a href="mailto:{$email|escape:'htmlall':'UTF-8'}">{l s='Contact our hotline' mod='blockcontact'}</a>{/if}

</div>

</div>

 

 

Hope this helps. Let me know,

pascal

Link to comment
Share on other sites

  • 7 months later...

 Hello!I followed all the steps above, copied the code in the section where PascaVG wrote this 

Looks like you missed some change from telnumber to telnumber2 or telnumber3

So please double/triple check if you added all changes correctly.

 

in my .tpl and .php files and the inputs and labels were added in my admin panel but in my browser it didn't applied yet. 

What did I do wrong? 

I attached a photo of my admin panel how it looks but the extra numbers didn't applied yet. 

 

What should I do? 

post-724118-0-02235700-1394026851_thumb.png

Link to comment
Share on other sites

Hi Klara,

 

Here some sample files from 1.5.6.2 version, where three telephone numbers are defined in the block contact info(s) module:

 

blockcontactinfos.php: backup your own file /modules/blockcontactinfos/blockcontactinfos.php

If you use 1.5.6.2, you can copy the file over the backupped one. If not, but you use a recent 1.5.x version, you can still try to copy the file over the old one, but there may be some complications. if you encounter problems, copy an original version back again, and instead compare the original and my file and check for lines with the text 'phone1', 'phone2', 'phone3'. Replace the original lines with only 'phone' for these phone1,phone2,phone3 ones.

 

blockcontactinfos.tpl: backup your own file themes/<your theme folder>/modules/blockcontactinfos/blockcontactinfos.tpl

If you use 1.5.6.2, you can copy the file over the backupped one. If not, but you use a recent 1.5.x version, you can still try to copy the file over the old one, but there may be some complications. if you encounter problems, copy an original version back again, and instead compare the original and my fileand check for lines with the text 'phone1', 'phone2', 'phone3'. Replace the original lines with only 'phone' for these phone1,phone2,phone3 ones.

 

blockcontactinfos_adjusted_files_Ps1562.zip

 

Hope this helps.

pascal

 

 

Link to comment
Share on other sites

  • 4 months later...
  • 3 months later...
  • 7 months later...
  • 1 year later...

I know this is a very old topic but i'm struggling with this in Prestashop 1.7.

 

In the footer of the store it shows the default information you can store in Shop Settings>Contact>Stores>Contact Details.

 

(i had to struggle where to enter this information by the way, it's very strange to me the general contact information has to be entered on a Stores page, since we don't have stores)

 

We want to show our company registration number as an extra line under the general company address, e-mail address and phone number. The strange thing is that there is a Registration field but whatever you enter there is not displayed in the contact information block.

 

The documentation says:

 

http://doc.prestashop.com/display/PS16/Store+Contacts+Preferences

 

  • Registration. Indicate your company's legal registration numbers, which depends on your country's legal system (Duns number in the USA, SIRET number in France, CNPJ number in Brazil, etc.). This shows that you are a fully registered business, thus giving a more reassuring opinion of your shop to your potential customers.

 

But why is this number not displayed in that block?? It doesn't make sense to me.

 

I tried searching for a .tpl file i can edit to add this information but can't find it. It seems to be very different from older Prestashop versions.

 

Please help.

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...