Archive for the ‘Magento eCommerce Tips’ Category

Magento eCommerce Tips – Magento is a great shopping cart and here are some tips.

23
Apr

Ok, so you have a nice custom module with a form – now you want to add basic javascript validation to it. Simple. Example,

<input type="text" name="first_name" value="" size="20" class="required-entry input-text" />

The class required-entry will make the field mandatory – this works for text-box and drop down.

If your form appears on the “one page checkout” page then, this is all you need to do.

If your form appears on its own then you will need to add this code at the bottom of your page:

<script type="text/javascript">
var customForm = new VarienForm('my-form-id');
</script>

Ensure that your form name and id are the same and that is what you need to pass to VarienForm

,

08
Mar

How to enable the default Magento contact form?

  1. System > Configuration > Contacts
  2. Click the ‘Contact Us’ section on this page. Set ‘Enable Contact Us’ to ‘Yes’
  3. Click the ‘Email Options’ section on the same page, just under it. Set the email address to which the comments should come, subject and email template.
  4. Click ‘Save Config’

How to add a custom field to the default Magento contact form?

  1. Open [magento_root]/app/design/frontend/default/default/template/contacts/form.phtml in your favorite editor
  2. Copy & paste an existing form field code on this script and rename the field to create new field. For example:
    This is the default  code in the file:

    <div class="input-box">
    <label for="email"><?php echo Mage::helper('contacts')->__('Email') ?> <span class="required">*</span></label><br />
    <input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text" />
    </div>
    <div class="clear"></div>
    <div class="input-box">
    <label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label><br />
    <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" type="text" />
    </div>

    This is how the modified code will look like:

    <div class="input-box">
    <label for="email"><?php echo Mage::helper('contacts')->__('Email') ?> <span class="required">*</span></label><br />
    <input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text" />
    </div>
    <div class="clear"></div>
    <!-- New Field Code-->
    <div class="input-box">
    <label for="website"><?php echo Mage::helper('contacts')->__('Website') ?></label><br />
    <input name="website" id="website" title="<?php echo Mage::helper('contacts')->__('Website') ?>" value="" class="input-text" type="text" />
    </div>
    <div class="clear"></div>
    <!-- End New Field Code-->
    <div class="input-box">
    <label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label><br />
    <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" type="text" />
    </div>
  3. Now go to, System > Transaction Emails.
  4. Click ‘Add New Template’
  5. In the ‘Load default template’ section, select ‘Contact Form’ template and click ‘Load Template’
  6. The template content will look like this:
    Name: {{var data.name}}
    E-mail: {{var data.email}}
    Telephone: {{var data.telephone}}
    
    Comment: {{var data.comment}}
  7. Add your new field in this content like this:
    Name: {{var data.name}}
    E-mail: {{var data.email}}
    Website: {{var data.website}}
    Telephone: {{var data.telephone}}
    
    Comment: {{var data.comment}}
  8. Enter a new ‘Template Name’ and click ‘Save template’
  9. Now go to, System > Configuration > Contacts
  10. Click the ‘Email Options’ section on this page and select the new template that you just created.
  11. Click ‘Save Config’

How to add a link to the contact form on the top menu bar?

  1. Open [magento_root]/app/design/frontend/default/default/template/catalog/navigation/top.phtml in your favorite editor
  2. After this line:
    <?php endforeach ?>

    Add a line like this:

    <li><a href="<?php echo $this->getUrl('contacts')?>"><?php echo $this->__('Contact Us') ?></a></li>
  3. Click the Magento cache; System > Cache Management

Reference links:

  1. http://www.magentocommerce.com/wiki/how_to/add_fields_to_contact_form
  2. http://www.richardcastera.com/2009/08/17/magento-add-additional-fields-to-the-contact-form/
  3. http://www.magentocommerce.com/boards/viewthread/21707/
  4. http://inchoo.net/ecommerce/magento/contact-form-in-magento/

, ,

08
Mar

To create Shopping Cart Price Rules go to Promotions -> Shopping Cart Price Rules and select Add New Rule.

We first enter a rule name and description. 25% off

Once those are in we select Active for Status.

You then need to select which Website the coupon will be good for. Main Website, Default website
You can select multiple items by holding Ctrl while selecting.

We are then going to make the Rule applied only with a coupon code, so we enter our code. 25% off

Now we have Uses Per Coupon and Uses Per Customer.  We then set the Users Per Customer to 1, so each customer will only be able to use the coupon once.

We then enter the dates the coupon is valid for and select the priority of the coupon. In this case we keep the priority as 0, the highest priority. If you remember from the Catalog Price Rules, the priority is used when you have 2 Rules applying to the same products. The rule with the highest priority (lowest number) will take effect first.

You can also decide whether or not each individual price rule will be made public in the price rules RSS feed that your customers can sign up for.

We are going to skip Conditions and come back to it since we are creating a simple coupon here. If this is skipped, the coupon will apply to all carts where the coupon code is entered. The products in the cart will not need to meet any conditions. To complete this coupon we select Actions from the left navigation.

Select Percent of Product Price discount (the other options being Fixed amount discount, Fixed amount discount for whole cart, and Buy X get Y free) and enter the value you want to discount. In this case it is 25.

We then want to enter a value for the maximum qty the discount will be applied to. Here we are keeping this blank

The Discount Qty Step controls how often the discount is applied. If we were to enter 8 here, the 25 percent discount would only apply after 8 items are added to the cart. If more than 8 items were added to the cart, the discount would remain as 10% or 8 items, until 16 items were added to the cart, at which point the discount would become 10% of 16 items. This would continue for every factor of 8. This would be useful for sellers who sell items in packages of 8 and only want to give discounts to each group of 8 items. In this case, we do not sell our items this way, so we will leave is field blank.

You can also select to combine the coupon amount with a free shipping offer, either just for the products the coupon is valid for, or for the whole order if one of those products is present in the cart. We aren’t feeling that generous in this case though, so we keep this dropdown at No.

In this case we are going to have the coupon valid on all products, so we will leave this section blank. If we wanted to specify this coupon to apply only to certain products, however, we could generate a set of conditions which the products must match in order to have the discount applied to them.

Now we select Save Rule and our 25% coupon is set to go, ready to be mailed in your newsletter and begin generating sales.

In the front end, the customer while ordering will be asked to enter the coupon code

Once he enters, the discount will be automatically calculated before the check out.

20
Jan

Quick Magento tip.

If you need to access the getConfigData() function from your controller do this:

Mage::getModel('<name of the model for this controller>')->getConfigData(<fieldname>);

For example if you want to call getConfigData() from the Mage_Mymodule_MyworldController controller then:

Mage::getModel('Mage_Mymodule_Model_Myworld')->getConfigData(<fieldname>);

, ,

03
Mar

Login to admin panel
Select Shopping Cart Price Rules from Promotions
Click on Add New Rule and enter the details
Click on Actions from the left hand side Menu and enter the details
Click Save Rule and that is it.

, , , , , , ,