Magento checkout problem

Magento checkout problem with custom theme in magento after selecting the payment method continue button doesnot work and onepage checkout become freezed.

If you are using Magento 1.4.1 or just upgraded any of your old Magento sites to the latest Magento version, then you may be getting a very weird error on your checkout page, that the checkout CONTINUE button on payment screen, either on Authorize.net or PayPal , just doesnt work.

The cause of this error is, Magento Team has introduced a new javascript file, which validates the credit card numbers, etc on the payment screen.

So, if you are using the default theme, then you should not get this problem.

But if you are using any custom theme, then you have to do some changes on your files.

Few symptoms of this problem is, you will see such errors,
Please verify the card with the issuer bank

Unable to initialize Express Checkout review.

CONTINUE button on Credit Card Form doesnt work.

I will give the instructions in details below, how to fix this issue :

Just add this js in your page.xml:

find <action method="addJs"><script>lib/ccard.js</script></action> under <block type="page/html_head" name="head" as="head">
replace it with
<action method="addJs"><script>prototype/prototype.js</script></action>
<action method="addJs" ifconfig="dev/js/deprecation"><script>prototype/deprecation.js</script></action>
<action method="addJs"><script>lib/ccard.js</script></action>

find <action method="addJs"><script>lib/ccard.js</script></action> under

<block type="page/html" name="root" output="toHtml" template="page/print.phtml">

<block type="page/html_head" name="head" as="head">

replace it with
<action method="addJs"><script>prototype/prototype.js</script></action>
<action method="addJs"><script>mage/translate.js</script></action>
<action method="addJs"><script>lib/ccard.js</script></action>

This must solve your complete problem .
But in case, its still not working, then here is another fix, which I got from another member from a forum,

I was experiencing the same issue: Nothing happens when you enter the credit card information and hit continue. After investigating with Firebug, it seemed that the method verifyCreditCard was not defined in validation.js.

You can fix this by pasting the following javascript code into validation.js under js->prototype in root folder:

/ Credit Card Validation Javascript
// copyright 12th May 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function validateCreditCard(s) {
// remove non-numerics
var v = "0123456789";
var w = "";
for (i=0; i < s.length; i++) {
x = s.charAt(i);
if (v.indexOf(x,0) != -1)
w += x;
// validate number
j = w.length / 2;
k = Math.floor(j);
m = Math.ceil(j) - k;
c = 0;
for (i=0; i<k; i++) {
a = w.charAt(i*2+m) * 2;
c += a > 9 ? Math.floor(a/10 + a%10;) : a;
for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;
return (c%10; == 0);

Now you have to disable Mage_Centinel from backend system->configuration->advanced to make it work in mozilla and firefox.
But it will work on IE without disabling centinel module.


How to redirect from one controller to product page in magento

While I was working on a module , it was required to redirect to a particular page,I tried to using header('lcoation')... .But it was not worked,So I searched in net How to redirect from a controller to product page, No solution Found .i tried myself and got a solution ,Which I am posting here.

In my controller i was sending the product Id and After doing some work I need to redirect to that product page.

I got this solution and worked.

$obj = Mage::getModel('catalog/product');
$_product = $obj->load($productId);

How to Create Custom login Session in magento

If you are trying to make a custom login module in magento then Magento have a default functionality to make a Custom login session,Which destroy automattically after some time, if you will be Inactive for a moment.

Here I am showing you How to set login session value and How to get login session value.

$sql='select * from `tablename` where `username`= "'.$username.'" and `password`="'.$password.'" ';
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
$row = $read->fetchAll($sql);

Now You have Logged in to your account. If you want to retrive login Session value then you need to write the following code

$login = Mage::getSingleton('core/session')->getlogin();


How to and Where to change default welcome message text in Magento

It's very simple go to admin panel of your site then go to system->config. Then click on Design tab from the left sidebar. now click on the Header tab .

Here you can Change your default welcome message in magento. You also able to change your Logo Image Alternet text. Logo Source file also.


How to change value of input text by jquery

I was searching in the internet for this solution ,But I couldn't find the proper solution.But I tried it myself so I think to share with all.

First i have created one input text with id inputText by this html code .
<input type="text" id="inputText" value="1" />

Now I wrote the following code in jquery to change value 1 to 5



How to show add Success message and add Error message in Magento

This is one of the easiest way to show Either Error message or Success message in magento for one time.If you are thinking to show an error message or success message one time when a page load then it is the best method to use in mganeto.

Show Error Message in frontend

$message = $this->__('Email Id Already Exist.');

Show Success message in frontend

$message = $this->__('You have Register Successfully');

If you wish show Success message or Error Message in Admin html then you need to write your code little bit different

Show Error Message in Admin page

$message = $this->__('1 row has been updated successfully');

Show Success Message in Admin page

$message = $this->__('Email Id Already Exist.');


How to check if an user is logged in or log out in Magento

This is Magento default feature. In top.link you can find login or logout link.But if you want to put somewhere login/logout button then you need to check whether a user logged in or not by the code given below.

if ($this->helper('customer')->isLoggedIn() )
echo '<a href="<?php echo $this->getUrl('customer/account/login/');?>">Login</a>';
echo '<a href="<?php echo $this->getUrl('customer/account/logout/');?>">Logout</a>';

How to overwrite cart controller add Action index Action in Magento

The Following Tutorial will Shows How to override cart controller Add Action or Index Action

First you need to give your Module name and Name_space ,I have taken Anjan as Namespace and override as Modulename
Now Create your module folders and files like below Instruction

1. Magento/app/code/local/Anjan/Override/etc/config.xml
2. Magento/app/code/local/Anjan/Override/controllers/CartController.php
3. Magento/app/etc/modules/Anjan_Override.xml

In config.xml Write the Foloowing code

<?xml version="1.0" encoding="UTF-8"?>
<Anjan_Override> <!--Change Anjan To Your Module NameSpace and Override to Your Module name-->
<Anjan_Override before="Mage_Checkout">Anjan_Override</Anjan_Override><!--Change Anjan To Your Module NameSpace and Override to Your Module name-->

In CartController.php write the following code

require_once 'Mage/Checkout/controllers/CartController.php';
class Anjan_Override_CartController extends Mage_Checkout_CartController
public function addAction()
echo 'I successfully Override Cart Controller';
public function indexAction()
echo 'I successfully Override Cart Controller';

In Anjan_Override.xml write the following code

<?xml version="1.0" encoding="UTF-8"?>

Now upload these files into your server,refresh your cache , the click on Add to cart button you can see the message is displaying . You can use die() statement to make sure whether is overrides or not .

How to Get Product details Using Product Id in Magento

If you got the product id then you can get details of a product by using the following method in magento.

$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id); // Enter your Product Id in $product_id
// get Product's name
echo $_product->getName();
//get product's short description
echo $_product->getShortDescription();
//get Product's Long Description
echo $_product->getDescription();
//get Product's Regular Price
echo $_product->getPrice();
//get Product's Special price
echo $_product->getSpecialPrice();
//get Product's Url
echo $_product->getProductUrl();
//get Product's image Url
echo $_product->getImageUrl();


How to Make http to https in magento login page register page checkout page and admin panel

Https is an important part in magento as customer or user gain trust and it increase web site's search engines rank also. To make your login page, register page, checkout page and admin panel as https you need to install SSL certificate into your server first.After Successful installation do the following process .
Go to System->Config->Web
then Click on Secure tab.
Change your base url to https://www.yoursite.com [ Important : Write HTTPS in your base url otherwise it will not work]
Make Use Secure URLs in Frontend to Yes
Make Use Secure URLs in Admin to Yes.

Seethe Below screenshot
Make http to https in magento login page register page checkout page and admin panel
Then Save config Clear your cache, Now go to your frontend then click on login page you can see that your login page is changed to https.

How to Read all files name in a folder using php

Write the below code to read filse name from an particular folder.

function dirFiles($directry) {
$dir = dir($directry); //Open Directory
while (false!== ($file = $dir->read())) //Reads Directory
$extension = substr($file, strrpos($file, '.')); // Gets the File Extension
if($extension == ".xml" || $extension == ".csv" || $extension == ".php" |$extension == ".txt") // Extensions Allowed
$filesall[$file] = $file; // Store in Array
$dir->close(); // Close Directory
asort($filesall); // Sorts the Array
return $filesall;

$array = dirFiles('/home/your absolute directory/');

foreach ($array as $key => $file)
echo $file; // Display Images
echo '<br />';

How to Reset all Folder and File permission in magento

There is two way to Reset all Folder and File permission in magento.

1. By using SSH

a. find . -type f -exec chmod 644 {} \;
b. find . -type d -exec chmod 755 {} \;
c. chmod 550 pear

2. By Using Magneto clean Up Tool
a.Download the magento clean up tool .
b.Unzip magento-cleanup.php to the root directory where Magento is installed.
c.Browse to http://yourdomain.com/magento-cleanup.php


How to Change admin default url in magento

It's very important to change default admin url in magento to save your website from hackers. For this you need to do little bit changes in your site.

1. Go to app/etc folder of your magento website and open local.xml
Instead of admin Write your new url (e.g: magAdmin).

2. Now go to your system cahce which located under var folder. Rename or delete the Cache folder.Clear all session. Now It's done. Visit the site admin by typing the new admin path.


How to change the Magento Email Templates

app\locale\en_US\template\email\ is the actual path where you can find all Email templates of magento. There are 20 html files .Edit Html file which you want,


How to remove index.php from url in magento

Default All url of a Magento website shows index.php .For search engine indexing it's necessary to remove index.php from all url.Then You need to login to your madento admin panel.

Go to System-> Configuration > Web > Search Engine Optimization. Make Yes from Use Web Server Rewrites Drop Down.

Now goto your Cache Management page and refresh your Cache ,then index.php will remove from all url of your magento website

How to change category page layout in Magento

Default Category page layout is written in page.xml file which resides in app/design/frontend/default/your-theme/layout/. Open Page.xml then change line number 35 or find .
<default translate="label" module="page">
<label>All Pages</label>
<block type="page/html" name="root" output="toHtml" template="page/3columns.phtml">
Change default 3columns.phtml to 1Coloumn.phtml or 2columns-left/right.phtml .Then save and upload it .
Clear your cache to see the effects.
Note :: Changing all page layout doesn't effect other pages of magento it effects only the category page. So don't hesitate to change this.


How to call a phtml file in magento cms page

You can't call a phtml file by writing php code in Magento admin panel as Magento admin panel doesn't support this. To call a PHTML write the folllowing code .

{{block type="core/template" name="a-name" template="cms/home.phtml"}}

inside template="" you can write your file path. and in name="" you can give proper and unique name , in type="" you can write your module directory also(e.g:- customer/account if you are calling login.phtml file).

One more way to call a phtml file. You can use your layout or xml file to do. For example i am going to attached home.phtml file which reside in cms folder of my thmeme template then I am writing the code given below

<reference name="content">
<block type="core/template" name="homepage" template="cms/homepage.phtml"/>

How to Get skin url in magento admin panel cms page

In frontend to calll skin url we write
<?php echo $this->getSkinUrl('');?>
To call Skin Url in Magento admin panel you have to write
<img src="{{skin url='images/your-image-name'}}" alt="">
{{skin url='images/your-image-name'}}
You can write css/style.css to call style.css in your theme

How to Get store url in magento admin panel cms Page

In frontend to calll store url we write
<?php echo $this->getUrl('');?>
But in admin Panel we can't write php or echo like statement. So to call base Url in Magento CMS Page or store url you have to write like the code given below.
<a href="{{store url='index.php'}}">Home</a>
{{store url='index.php'}}
This the actually way to call store url in admin panel.
You can use your required link instead of index.php (e.g:- contacts to call Contact us page).


How to Get value of a select box in JavaScript

If you are using Id to get a select box value then it's little bit easier . If you don't have id in your select box then you need to use name attribute to select the select box. I have used name tag to get the select box value.

<script type="text/javascript">
function slectBox()
var aa= document.form.selectBox.selectedIndex;
var ab= document.form.selectBox.options[aa].value;

<form action="" name="form">
<select name="selectBox">
<option value="1">one</option>
<option value="2">Two</option>
<input type="button" onclick="slectBox()" value="clickme" />

This is the example how it works.try it


Get Product price excluding Tax class in Magento

Normally in magento Price shown including Tax.But if you want to show Price Excluding Tax then you need to call the following helper class.

<?php echo $this->helper('checkout')->formatPrice($_product->getPrice())
// For Special Price write this
echo $this->helper('checkout')->formatPrice($_product->getSpecialPrice()) ?>


get skin url, get js url, get media url, get store url ,get base url in magneto

These are the following methods to get Magento Base Url, Magento Skin Url, Magento Media Url, Magento Js Url.to get all write the following code

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); or you can write $this->getUrl();
e.g:- http://yoursite.com/index.php/

Get Magento Media Url
e.g:- http://yoursite.com/media/
Get Magento Skin Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); or you can write $this->getSkinUrl();
e.g:- http://yoursite.com/skin/

Get Magento Store Url
e.g:- http://yoursite.com/

Get Magento Js Url


How to find your blogger blogs sitemap Url

To find the location of your sitemap, use the following steps:

1. Open up your web browser, and type in your Blogger blog’s URL.
2. At the end of the URL add robots.txt.

For example, if the URL of your blog is http://myblog.blogspot.com, then enter http://myblog.blogspot.com/robots.txt
3. Some text should now be displayed in your browser. Look for a line that starts with Sitemap:. The URL after that label is the location of your sitemap.

Using the example above, the line would look like:

Sitemap: http://myblog.blogspot.com/feeds/posts/default?orderby=updated
4. Back in Google’s Webmaster Tools, the domain name part of the URL would already be included, so you would just need to specify the feeds/posts/default?orderby=updated portion of the sitemap URL. If other sites are able to accept a sitemap, then you may need to include the entire URL


How to Show static block only on homepage in magento

If you are in header.phtml file then you can call $this->getIsHomepage();

But if you are not there then you must have to create instance of Mage_Page_Block_Html_Header(); then write the following code to check homepage

$ref = new Mage_Page_Block_Html_Header();
if($ref->getIsHomePage()){ ?>
<div class="homepage"><?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('Your_StaticBlock_Id')->toHtml();?></div>