How to Add New Field Contact Form in magento


Step 1: Add field to phtml file

Go to app -> design -> frontend -> yourpackage -> yourtheme -> template -> contacts -> form.phtml

If you want to add required field:

1
2
3
4
<li>
    <label for="email"><em>*</em><?php echo Mage::helper('contacts')->__('Company Name') ?></label>
    <div class="input-box"><input name="company" id="company" title="<?php echo Mage::helper('contacts')->__('Company Name') ?>" class="input-text required-entry validate-email" type="text" /></div>
</li>

If you want to add non-required field:

1
2
3
4
<li>
    <label for="telephone"><?php echo Mage::helper('contacts')->__('Company Name') ?></label>
<div><input name="company" id="company" title="<?php echo Mage::helper('contacts')->__('Company Name') ?>" value="" type="text" /></div>
</li>

Magento Contact us Form

Step 2: Add new field detail in email

Open admin panel and go to System -> Transactional E-mails -> Add New Template
Then From the ‘Template’ dropdown menu choose ‘Contact Form’ and then click on ‘Load Template’. You’ll see the current email content, so you’ll simply need to add your new piece of data:

1
2
3
4
5
6
7
Name: {{var data.name}}
E-mail: {{var data.email}}
Telephone: {{var data.telephone}}
Company Name: {{var data.company}}
Comment: {{var data.comment}}

Magento Contact Form Template

Step 3: Apply nwe template to contact email

Go to System -> Configuration -> Contacts. In the ‘Email Options’ section, choose your new template under the ‘Email Template’ dropdown menu and save.

Contactus Form Magento

 

particular search result in magento


app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php

Now Go to the following function in this file

public function prepareResult($object, $queryText, $query)

You have to change the following line

$likeCond = '(' . join(' OR ', $like) . ')';

To

$likeCond = '(' . join(' AND ', $like) . ')';

Now change the Search Type to “LIKE” from catalog search section in admin.

Magento: Add a custom field to the Contact Us Form


Update the Contact Us form template

Firstly you need to edit the contact form template.
If using the default theme, this code will be located in
/magento/app/design/frontend/base/default/template/contacts/form.phtml

Add the following markup to the template in the desired position:

<div class="input-box">
    <label for="where-hear"><?php echo Mage::helper('contacts')->__('Where did you hear about us?') ?> <span class="required">*</span></label><br />
    <select name="where-hear" id="where-hear" style="width:300px" class="required-entry">
        <option value="" selected>Please select...</option>
        <option value="Google">Google</option>
        <option value="Magazine">Magazine</option>
        <option value="Word of Mouth">Word of Mouth</option>
        <option value="Other">Other</option>
    </select>
</div>

Note the use of class=”required-entry” on the select element.. This tells the default javascript validation that this field is required. If the user tries to submit the form without choosing an option, then it will throw an error and highlight the field.

So that takes care of the form, now you need to set up a custom email template that includes the new field.

Create a custom transactional email template

Navigate to the following screen in your Magento admin:
System > Transactional Emails

  1. Click Add New Template
  2. In the top block (Load default template), select “Contact Form” from the drop box and click Load Template
  3. In the Template Information block, set the Template Name to “Custom Contact Form”
  4. In the Template Content field, add the following line where you want it to appear in the email:
    Where did you hear about us?: {{var data.where-hear}}

Assign the custom email template

Navigate to the following screen in your Magento admin:
System > Configuration > General > Contacts

In the Email Options block, set the Email Template to “Custom Contact Form”.

Click Save Config and you’re all done.

how to use increment quantity in magento


jQuery(document).ready(function($){
// Your code here

jQuery(“div.quantity”).append(”).prepend(”);
jQuery(“.plus”).click(function()
{
var currentVal = parseInt(jQuery(this).prev(“.qty”).val());

if (!currentVal || currentVal==”” || currentVal == “NaN”) currentVal = 0;

jQuery(this).prev(“.qty”).val(currentVal + 1);
});

jQuery(“.minus”).click(function()
{
var currentVal = parseInt(jQuery(this).next(“.qty”).val());
if (currentVal == “NaN”) currentVal = 0;
if (currentVal > 0)
{
jQuery(this).next(“.qty”).val(currentVal – 1);
}
});
});

getProduct(); ?>
__(‘Add to Cart’); ?>
isSaleable()): ?>

isGrouped()): ?>

<input type="text" name="qty" id="qty" maxlength="12" value="getMinimalQty($_product) ?>” title=”__(‘Qty’) ?>” class=”input-text qty” />

<button type="button" title="” class=”add-to-cart ” onclick=”productAddToCartForm.submit(this)”>
getChildHtml(”, true, true) ?>