Display Products in shopping cart in a drop down format in Magento

You might have seen the cart summary drop down in many websites as shown in the image below. Making such a drop down is pretty easy using Magento. You just need to know little bit of jquery for it.
Follow the below steps to build one for you

1) If you would have observed our requirement is to display the recently added products in cart drop-down. So we will use the siderbar file for cart which has already been implemented in Magento.
2) Create a copy of file sidebar.phtml and name it say cart_top.phtml.
3) Add these three class in first three div. These classes will be used in Jquery. The classes will look somewhat similar to this

1st Div : <div class=”block block-cart main-div-top icon-down”>
2nd Div : <div class=”block-title top-mini-title”>
3rd Div : <div class=”block-content top-mini-content” style=”display:none;”>

Continue reading


Registration Mobile number validation In Magento

Some time in account registration we need validate mobile no,
for that use this code

<input type="text" name="telephone" id="telephone" value="<?php echo $this->htmlEscape($this->getFormData()->getTelephone()) ?>" 
title="<?php echo $this->__('Telephone') ?>" class="input-text validate-mobileno" />

Replace script

 <script type="text/javascript">
 var dataForm = new VarienForm('form-validate', true);


 <script type="text/javascript">
if(Validation) {
['validate-mobileno','Enter correct mobile number (Eg:919986858483)',
var timePat ="^((\+){0,1}91(\s){0,1}(\-){0,1}(\s){0,1}){0,1}9[0-9](\s){0,1}(\-){0,1}(\s){0,1}[1-9]{1}[0-9]{7}$";
// var matchArray = v.match(timePat);
if(v.length > 0){
if(v.length !=12){
    return false;
   }else if(v[0] != 9 || v[1] != 1 ){
    return false;
   }else if(v[2]!=9 && v[2]!=8 && v[2]!=7){
    return false;
return true;

}else {
return false;

 var dataForm = new VarienForm('form-validate', true);

Export the database table as CSV format using PHP

This code need some files those files are,
as in the db.php file, make this.

database name –> wallstreet
table name–> export_table
column names –> id,name,place
and as you, here i just declare what i have given in.

$conn = mysql_connect('localhost', 'root', '') or die(mysql_error());
$db=mysql_select_db('wallstreet', $conn) or die(mysql_error());



//header to give the order to the browser
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=exported-data.csv');

//select table to export the data
$select_table=mysql_query('select * from export_table');
$rows = mysql_fetch_assoc($select_table);

if ($rows)
$rows = mysql_fetch_assoc($select_table);

// get total number of fields present in the database
function getcsv($no_of_field_names)
$separate = '';

// do the action for all field names as field name
foreach ($no_of_field_names as $field_name)
if (preg_match('/\\r|\\n|,|"/', $field_name))
$field_name = '' . str_replace('', $field_name) . '';
echo $separate . $field_name;

//sepearte with the comma
$separate = ',';

//make new row and line
echo "\r\n";

this file is just for do the download, just give the link anchor tag,
usually you know to make just click export the data,
for that just give the link on anchor link, that will export the data table.

<a href="export.php"> export the database table </a>

Check if product is set as New in Magento.

Magento has a great functionality to mark product as New within a range of date. At times we want the new product to be highlighted with the TAG say NEW as shown in the figure below.


To make such a tag in product listing page you need to follow below steps

1) Goto app/design/frontend/YOURTHEME/default/catalog/product/list.phtml
2) Add the following code at appropriate place in your file. This code will check the start date and end date of the product marked as new and will display the tag accordingly. Continue reading

Powerful WordPress Tips And Tricks

Piyush Pujara

I’ve been working with WordPress since the dawn of time, and even though I peek at the source code regularly, I still discover new tips and tricks. I’ve compiled my own list of 21 techniques that are handy, clever, fun or best practices rarely followed. I hope everyone finds something new in the list!

1. WordPress Has A Ton Of Built-In Scripts

Using the great wp_enqueue_script() and wp_enqueue_style(), you can include styles and scripts easily with dependency management. But did you know that WordPress has a lot of scripts already built in? jQuery, many elements of jQuery UI, jQuery Form, SWF Object, Tiny MCE, Jcrop and Thickbox are just some the better known ones. The whole list can be found in the WordPress Codex. If you’re interested in learning how to use the enqueue functions effectively, I recommend .The Developer’s Guide to Conflict-Free JavaScript and CSS in WordPress right…

View original post 287 more words

Creating a Count Down Timer when Customer Logs Out From Account in Magento

Magento has a very Lame Layout Screen when customer logs out. To make it little interesting I thought why not add a count down timer over there. So this is how i made a count down timer using JavaScript.

Goto : frontend/default/YOURTHEME/template/customer/logout.phtml

Now Create a span where in between which you want to display a timer.

<span id=”timer”>5</span>

After that add following Javascript code in the file :

<script type=”text/javascript”>
window.onload = CreateTimer(“timer”, 5);
var Timer;
var TotalSeconds;

function CreateTimer(TimerID, Time) {
Timer = document.getElementById(TimerID);
TotalSeconds = Time;

window.setTimeout(“Tick()”, 1000);

function Tick() {
TotalSeconds -= 1;
if(TotalSeconds == 0){
location.href = ‘<?php echo $this->getUrl() ?>’
return 0;
window.setTimeout(“Tick()”, 1000);

function UpdateTimer() {
Timer.innerHTML = TotalSeconds;

Please Note : Comment out the default redirection code ie: setTimeout(function(){ location.href = ‘<?php echo $this->getUrl() ?>’},5000)

This is it. Now enjoy your timer when cutomer logs out. I haven’t explained the code in detail as it is pretty simple. If you face any problem in it please post it as a comment.