Merchant Stories

Twitter Handle: Why Your Ecom Store Needs One

Oct 9, 2014 4 min read 301 views
Listen audio
Twitter Handle: Why Your Ecom Store Needs One

There are currently a lot of social services that allow not only monitoring of events in any part of the world but also use their data in promotion and improvement of your business.

One of the most popular social networks in the world is Twitter. Let us review how to add the line ‘Twitterhandle’ into the registration form in Magento ®.

Why is the Twitter Handle necessary?

Many services that create and store visiting statistics data of web shops, blogs and diaries use information from Twitter in their work. These include link referrals, reviews, etc. If you wish to know your customers’ opinion about your store – this is the best way for you to uncover it.

Besides, this social network will help you significantly increase the number of potential customers and monitor the activity of customers you already have. It is quite simple to add the ‘Twitterhandle’ field to the registration form, all you need to do is correct the code. Also, check our free Social Connector.

Many web store owners tend to underestimate the power of Twitter. This is what this microblog network can give you:

1. Information about your customers, their problems, needs, and requirements;

2. Public opinion about the products of your company and about other companies (your possible competitors);

3. Possibility to help your customers make the right choice or give them an idea of buying this or that product;

4. Free promotion of your web store products;

5. Free advertisement of your products directly to the target audience.

How to add Twitterhandle

As we mentioned in other articles, Magento ® uses the following architecture of data: Entity – Attribute – Value. Based on that information, you only need to add another attribute in order to generate the line for Twitter. For that, you need to edit the file register.phtml. You will find it at the path app, then app\code\local\YourNamespace\Appname\sql\yournamespace_appname_setup\mysql4-install-1.0.php

Open the file in the editor and paste the following code at the beginning:

<?php
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer', 'twitter', array(
'label' => 'Twitter handle',
'type' => 'varchar',
'input' => 'text',
'visible' => true,
'required' => false,
'position' => 1
));
?>

 

In order to configure in which place the social network line will be located, find the following part in the file:

<li>
<label for="email_address"><?php echo $this->__('Email Address')
?><span class="required">*</span></label><br/>
<input type="text" name="email" id="email_address" value="<?php
echo $this->htmlEscape($this->getFormData()->getEmail()) ?>"
title="<?php echo $this->__('Email Address') ?>" class="validateemail
required-entry input-text" />
</li>

 

You can find it using the combination of ctrl + F.

After the closing tag </li> paste the following code:

[b]<li>
<label for="twitter"><?php echo $this->__('Twitter handle') ?></
label>
<div class="input-box">
<input type="text" name="twitter" id="twitter" value="<?php
echo $this->htmlEscape($this->getFormData()->getTwitter()) ?>"
title="<?php echo $this->__('Twitter') ?>" class="input-text" />
<label for="twitter" style="color: #ccc;font-size:
85%;">Example: @packtpub</label>
</div>
</li>[/b]

 

Note that this line will be highlighted in bold text to attract attention, you can remove this point if necessary.

Remember that sometimes your customers will need to update the information on their social network page. In order to let them do it directly from your store, you need to modify the file edit.phtml.

Open the file in catalog customer/form/ and look for the following code:

<li>
<label for="email" class="required"><em>*</em><?php echo $this-
>__('Email Address') ?></label>
<div class="input-box">
<input type="text" name="email" id="email" value="<?php
echo $this->htmlEscape($this->getCustomer()->getEmail()) ?>"
title="<?php echo $this->__('Email Address') ?>" class="input-text
required-entry validate-email" />
</div>
</li>

 

Below that code add the following:

[b]<li>
<label for="twitter"><?php echo $this->__('Twitter handle') ?></
label>
<div class="input-box">
<input type="text" name="twitter" id="twitter" value="<?php
echo $this->htmlEscape($this->getCustomer()->getTwitter()) ?>"
title="<?php echo $this->__('Twitter') ?>" class="input-text" />
<label for="twitter" style="color: #ccc;font-size:
85%;">Example: @ferdous</label>
</div>
</li>[/b]

 

After that, you need to change the template configuration file. For that, go to app/code/core/Mage/Customer/etc/, then open the file config.xml.

Basic changes will be done in Global, you need to replace that block with the following:

<global>
<fieldsets>
<customer_account>
<prefix><create>1</create><update>1</update><name>1</name></
prefix>
<firstname><create>1</create><update>1</update><name>1</
name></firstname>
<middlename><create>1</create><update>1</update><name>1</
name></middlename>
<lastname><create>1</create><update>1</update><name>1</name></
lastname>
<suffix><create>1</create><update>1</update><name>1</name></
suffix>
<email><create>1</create><update>1</update></email>
<twitter><create>1</create><update>1</update></twitter>
<password><create>1</create></password>
<confirmation><create>1</create></confirmation>
<dob><create>1</create><update>1</update></dob>
<taxvat><create>1</create><update>1</update></taxvat>
<gender><create>1</create><update>1</update></gender>
</customer_account>
</fieldsets>

 

Now you are almost finished. You only need to add an object attribute. Go to app/code/core/Mage/Customer/Model/Entity/ and open file setup.php. Locate the fields responsible for customers’ email address, but remember that after any update of Magento ® all modifications in the core files will be erased. In that case, do not forget to add them again:

'email' =>array(
'type' => 'static',
'label' => 'Email',
'class' => 'validate-email',
'sort_order' => 60,
),

 

Add the following code:

'twitter' => array(
'label' => 'Twitter',
'required' => false,
'sort_order' => 65,
),

 

It is done. Save the changes and check how it works. The code was taken from http://magento-forum.ru

If you would like GoMage specialists to help you install Twitterhandle in Magento ® please email us directly or leave a comment on this article.

That's where you contact us!

    By submitting this form you agree to GoMage's Terms of Use and Privacy Policy
    woo-hoo! Now its time to keep checking your inbox, as we will be getting in touch soon. Promise :)
    oops! Thanks. But it seems like some kind of technical issues stop you from meeting GOMAGE. Could you try again?