Monthly Archives: January 2010

Add Shipping cost in PayPal Information In Zen-cart

Find Out this line from /includes/modules/payment

/*around lines 167
$this->totalsum = $order->info['total'];

/*Then replace by This lines 

$this->totalsum = $order->info['total'] - $order->info['shipping_cost'];

Also find this lines

/*around lines 167
'shipping' => $order->'0.00',

/*Then replace by This lines 

'shipping' => $order->info['shipping_cost'],

This is it.


Check form field empty before submit

<script type="text/javascript" language="JavaScript">
function nameempty()
    if ( document.form.first_name.value == '' )
        alert('No Name was entered!')
        return false;
	 if(document.form.last_name.value == '')
		alert('No Last name entered!')
		return false;
	 if(document.form.address1.value == '')
		alert('No Address entered!')
		return false;
	 if( == '')
		alert('No City entered!')
		return false;
	 if( == '')
		alert('No Zip code entered!')
		return false;
 	 if(document.form.state.value == '')
		alert('No State entered!')
		return false;
	 if( == '')
		alert('No Country entered!')
		return false;

<form action="paypal.php" method="post" name="form" onSubmit="return nameempty();">
Fist Name:<input type="text" name="first_name" value=""><br />
Last Name:<input type="text" name="last_name" value=""><br />
Address1:<input type="text" name="address1" value=""><br />
Address2:<input type="text" name="address2" value=""><br />
City: <input type="text" name="city" value="" /> <br/>
State:<input type="text" name="state" value=""><br />
<input type="hidden" name="item_name" value=""><br/>
<input type="hidden" name="amount" value=""><br/>
Zip:<input type="text" name="zip" value=""><br />
Country:<input type="text" name="country" value=""><br />

<input type="image" src="" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" >
<img alt="" border="0" src="" width="1" height="1">

General Terms in magento!!

This are the general terms in magento which might useful to all:


To retrieve a Magento database connection we must first get a resource. If you
require a generic database handle, you can use the name core/resource for the resource
name, and core_write for the connection name. The Mage::getSingleton
method keeps track of all classes loaded through it as singletons and returns a previously
initialized object if the name matches. Each module may have its own
database settings – usernames and passwords – or it might even be connecting to
a separate database server, so be sure to use the most appropriate resource name
when you can. In a default setup, all of Magento’s connections use the settings of
default_setup, default_write, or default_read.
$write = Mage::getSingleton(’core/resource’)
if ($write instanceof Zend_Db_Adapter_Abstract) {
echo get_class($write);
//outputs: Varien_Db_Adapter_Pdo_Mysql


The role of a resource in Magento is to manage database connections. Resources
are defined under the global XML tag of any config.xml file. To make a new
database connection you would add XML like the following to any config.xml file.
Each resource has a name of the form module/name and each connection has a
name. Connection names are generally of the pattern module_read, module_write,
or module_setup.

         <initStatements>SET NAMES utf8</initStatements>

The format should be mostly self explanatory, most of these values end up being
passed to the Zend_Db_Adapter_Abstract class. The initStatements tag is executed
upon every connection to the database server. The model tag seems unnecessary,
perhaps it was part of an idea that didn’t pan-out completely. The type tag refers
to one of two connection types defined in the global app/etc/config.xml file. Only
pdo_mysql and mysqli are implemented at the moment.

Add a page in magento


1. Login as admin, Then select ‘Manage Pages’ from CMS menu.
2. Click ‘Add New Page’ Button to create a page.
3. In the New Page:

a) In General Information tab enter following details:
Page Title: Test Page
SEF URL Indentifier: test1
Store View: All Store Views
Status: Enabled
Content: Enter some text here..

b) Custome Design: Select your own layout from this tab
Select Layout: Three Column (you can select any layout)

c) Meta Data: If you want to add Keywords and Descriptions

Then click on ‘Save Page’ button. Now your test page is ready.

4. Now we have to create a new menu to link this page. Open app/design/frontend/default/default/template/catalog/navigation/top.phtml

Enter following line just above the foreach statement.

<li><a href="<?php echo $this->getUrl('test1')?>"><?php echo $this->__('Test') ?></a></li>

Here test1 is the SEF URL Identifier and Staff is the new menu name.

Now your menu is ready. Go to magento frontend and click on ‘Staff’ menu to see your new page.

You can also add this page in footer
For this you have to go Admin->CMS->Static Blocks->Footer links
And add this code

<li><a href="{{store url=""}}about-magento-demo-store">About Us</a></li>
<li ><a href="{{store url=""}}customer-service">Customer Service</a></li>
<li class="last"><a href="{{store url=""}}test1">Test</a></li>

Create a form and send mail using loop and on page submit

<div class="box  base-mini" style="background:#E7F1F4">
<div class="head">
   <h4>Send Mail</h4>
 <p style=" color:#24394C; font-family:Arial; font-size:10px; font-weight:bold;" align="center">If you did not find the cell phone you are looking for</p>
<form method="post" action="">
<table width="180px">
<td style=" white-space:nowrap" >Cell:</td><td><input size="18" type="text" name="name"/></td>
<td style=" white-space:nowrap">Model:</td><td><input  size="18"type="text" name="number"/></td>
<tr><td style=" white-space:nowrap">Email:</td><td><input  size="18"type="text" name="your"/></td>

<tr><td align="right" colspan="2" valign="bottom"><input type="submit" name="submit" value="Send"/></td>

if (isset($_POST['submit'])){
	if ($_REQUEST['name'] != NULL && $_REQUEST['number'] != NULL && $_REQUEST['your'] != NULL ) {
	$va1 = $_POST['name'];
	$va2 = $_POST['number'];
	$va3 = $_POST['your'];
 	$to = array('','');
	$to1 = $to[$i];
	$subject = "New Mobile For Your Store";
	$message ="Cell Name: " .$va1.",  "."Model: ".$va2;
	echo $to1;
	$from = $va3;
	$headers = "From: $from";
	echo  '<p style="color:#236E2D" align="center" >'."Mail Sent".'</p>';
	if ($_REQUEST['name'] == NULL || $_REQUEST['number'] == NULL || $_REQUEST['your'] == NULL ) {
	echo  '<p style="color:#FF0000" align="center" >'."Plz Enter Missing Field ".'</p>';

%d bloggers like this: