Magento template variable $customer

Magento template variable $customer

September 15, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento template variable $customer

Unlocking Customer Data in Magento: A Guide to the $customer Variable

Are you working on customizing Magento’s email templates but struggling to access customer data? You’re not alone! The $customer variable is a powerful tool that lets you pull essential information about your site’s users directly into your email content. Let me walk you through the key properties of this variable and show you how to use them effectively.

Understanding the $customer Variable in Magento

The $customer variable represents an instance of the Mage_Customer_Model_Customer model, which encapsulates all the relevant data about a registered user on your site. This includes personal details like name and email, shipping addresses, tax information, and more.

You can access this variable within any Magento template file—whether it’s for customer emails, order confirmations, or account management pages. The syntax is simple: just wrap the property you want to display in double curly brace tags (i.e., {{ }}).

Accessing Common Customer Properties

Now let me share some of the most common properties you can extract from the $customer variable:

  1. Customer Name: To display the customer’s full name, use the name attribute.

    <p>Dear {{$customer.name}},</p>
    
  2. Email Address: The email property holds the customer’s registered email address.

    Your order confirmation will be sent to: <a href="mailto{{$customer.email}}">{{$customer.email}}</a>
    
  3. Shipping and Billing Addresses: Magento allows you to access multiple addresses for a single customer. The $customer->getAddresses() method returns an array of Mage_Customer_Model_Address objects.

    <p>Shipped To: <br />
       {{var $address = $customer->getShippingAddress()}}
       {{var address_street1 = $address->getStreet(1)}}
       {{var address_street2 = $address->getStreet(2)}}
       {{var address_city = $address->getCity()}}
    
    </p>
    
  4. Tax/VAT Number: This is stored in the taxvat property.

    <p>Your Tax/VAT Number: <strong>{$customer.taxvat}</strong></p>
    

A Word of Caution

Remember, when dealing with personal customer data, it’s crucial to follow best security practices and comply with relevant privacy regulations (like GDPR). Never expose sensitive information like full addresses or credit card details in your emails without proper encryption.

Exploring More Customer Data in Magento

If you need access to more advanced properties or want to customize the $customer object further, I recommend checking out these resources:

Conclusion

The $customer variable is a treasure trove of valuable information for your Magento store. With the properties I’ve outlined above, you should now be able to create more personalized and informative email content for your customers.

Don’t hesitate to experiment with different attributes and methods—Magento’s template system is quite flexible once you get the hang of it. Just remember to always test changes thoroughly in a safe environment before pushing them live.

Happy coding! Let me know if you have any other questions about Magento development or need further assistance customizing your site.

Themes Email Orders Customers

Our network