Magento

9
Jul

How to Add Confirmation email field in magento registration form using class validate-cemail?

The following method allows you to add confirmation email address field in your customer registration or newsletter page.

Create a javascript file called validation.js under “js/email/validation.js”

[php toolbar=”true” classname=”one_line”] Validation.addAllThese([

[‘validate-cemail’, ‘Please make sure your emails match.’, function(v) {
var conf = $(‘confirmation’) ? $(‘confirmation’) : $$(‘.validate-cemail’)[0];
var pass = false;
var confirm;
if ($(’email’)) {
pass = $(’email’);
}
confirm =conf.value;
if(!confirm && $(’email2′))
{
confirm = $(’email2′).value;
}
return (pass.value == confirm);
}],
]);
[/php]

Read more

9
Jul

Using Magento’s Built-In AJAX Submit With Validation

I’m creating a custom module and I want to be able to submit the form via Magento’s built-in AJAX. Also, I want to validate the user input to ensure I don’t get a database full of blanks!

Magento makes hooking into the existing functionality really quite easy. Let’s begin with the form.

Read more

9
Jul

Magento: Form validation

Most important thing besides assigning class names to form in magento is that little piece of JavaScript below the form. Remember to pass form id into the new VarienForm object.

Basically that’s it. Constructing the form this way, automatically makes your form reuse already existing validation code, the one that the rest of the shop is using.

Below is a full list of validate class and its error message that I found in prototype lib.

* validate-select

Please select an option.

Read more

9
Jul

Magento: Get customer details

Magento get the logged in customer details like customer id, name, email, etc. Check if customer is already logged in or not, if they are logged in then get all the data using customer session object and use it as per the requirement.

Input:

[php toolbar=”true” classname=”one_line”] if (Mage::getSingleton(‘customer/session’)->isLoggedIn()) {
$customer = Mage::getSingleton(‘customer/session’)->getCustomer();
$customerData = Mage::getModel(‘customer/customer’) ->load($customer->getId())->getData();
Mage::log($customerData);
}
[/php]

Read more

9
Jul

Magento : Get Url

Get Url in phtml files

1. Get Base Url :

[php toolbar=”false” classname=”one_line”] Mage::getBaseUrl(); [/php]

2. Get Skin Url :

[php toolbar=”false” classname=”one_line”] Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); [/php]

(a) Unsecure Skin Url :

If you need to get the skin url, the most common place you’d need to get it is from within a template file. If that is the case for you, this is how you can do it:

Read more