How to pre-populate a form with customer's data

This area is devoted to Magento Form Builder SmartFormer Gold. Please ask questions, report bugs and share ideas here.

How to pre-populate a form with customer's data

Postby IToris team » Wed Nov 10, 2010 7:18 pm

If you need some information to be pre-filled on your forms, like names or emails of your customers - it can be done in the following way:

1. Create a form

2. Press the field to be pre-populated. You will see the box with its properties.

3. Find value property. There will be an icon near it "Add PHP script". Click this icon.



The following scripts can be added:

Pre-populate full name:

Code: Select all
echo Mage::getSingleton('customer/session')->getCustomer()->getName();


Pre-populate last name:
Code: Select all
echo Mage::getSingleton('customer/session')->getCustomer()->getLastname();


Pre-populate first name:
Code: Select all
echo Mage::getSingleton('customer/session')->getCustomer()->getFirstname();


Pre-populate email address:
Code: Select all
echo Mage::getSingleton('customer/session')->getCustomer()->getEmail();



N.B. Your customers should be logged in so that their data is pre-populated.
IToris team
Site Admin
 
Posts: 1355
Joined: Mon Jan 19, 2009 12:33 pm

Postby Khris » Thu Feb 10, 2011 9:22 pm

What would be the correct syntax for Smartformer Gold for Joomla?
Khris
 
Posts: 6
Joined: Thu Feb 10, 2011 9:20 pm

Postby IToris team » Mon Mar 28, 2011 11:16 am

Hello Khris,

Please read this topic. This topic provide instruction how auto-population of date and time with the correct syntax for Smartformer Gold for Joomla
IToris team
Site Admin
 
Posts: 1355
Joined: Mon Jan 19, 2009 12:33 pm

Re: How to pre-populate a form with customer's data

Postby five5 » Mon Dec 05, 2011 7:43 am

Can you elaborate on the PHP required to pre-populate fields with:
Default billing address (either in one text area or seperate fields (street, city, postcode)
Default billing address phone number.

Thanks.
five5
 
Posts: 1
Joined: Mon Dec 05, 2011 7:41 am

Re: How to pre-populate a form with customer's data

Postby IToris team » Thu Jan 12, 2012 3:16 pm

Hello Five5,

Please use the following code:

Code: Select all
$address = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBillingAddress();
echo $address->getData('postcode');

/*
   replace post code with one of these:
   
  firstname
  lastname
  company
  city
  country_id
  region
  postcode
  telephone
  region_id
  street
  customer_id
 
*/


IToris Team
IToris team
Site Admin
 
Posts: 1355
Joined: Mon Jan 19, 2009 12:33 pm


Return to SmartFormer Gold for Magento

Who is online

Users browsing this forum: No registered users and 1 guest