Picture of Prepopulate Data Script (MegaEdit)

Prepopulate Data Script (MegaEdit)

What Is the Prepopulate Data Script?

The Prepopulate Data Script allows you to automatically fill specific text fields in your MegaEdit product with data from your users’ accounts. This is especially helpful for personalizing products (e.g., business cards, address labels) with the user’s name, email, address, or any custom data fields you have enabled in their profile.

1. How to Enable Prepopulate Data

  1. Go to Admin > Catalog > Product Types > MegaEdit > MegaEdit Products.
  2. Edit the product where you want to enable the script.
  3. Go to the Scripts tab.
  4. Enable the “Prepopulate Data Script”.
  5. Save changes.

When enabled, a new button called “Prepopulate Data” appears in the MegaEdit interface whenever you select a text field.

 

2. How to Use in MegaEdit

  1. Open the product in your store (as a normal, logged-in customer).
  2. Select a text field in the MegaEdit design.
  3. Click the “Prepopulate Data” button. A menu will appear showing the standard user-profile fields (e.g., first name, last name, email, etc.).
  4. Select one of the available data fields.
    • For example, “Customer Full Name” or “Customer Email.”
    • Once selected, the text field is “tagged” so that it will pull the correct user information.
  5. Save your design (via Menu > Save product default).

Note: You can only assign one data field per text field (e.g., one text field can’t hold both first name and email at the same time in this setup).

3. Available Data Fields

The script supports a variety of standard fields from the user’s profile:

  • Customer Info: Full Name, First Name, Last Name, Email, Gender, Title, Date of Birth, Phone, Fax, Company Name, etc.
  • Address Fields: Address Line 1, Address Line 2, City/Town, County/Region, Country, Postal Code, etc.
  • Custom Fields: If you have custom fields configured in your registration (e.g., Custom Field 1, 2, 3), you can use these by selecting or manually entering the tag:

    prepopulate_Custom1 prepopulate_Custom2 prepopulate_Custom3

4. Important Update: New Fallback Logic vs. Legacy Logic

We’ve introduced new fallback logic to better manage how data is retrieved between Customer Info, Billing Address, and Shipping Address. Previously, certain fields always came from Customer Info, while others came from billing/shipping addresses, which could cause confusion or inconsistencies.

New Default Logic (Recommended)

  1. Customer Info: First, the script checks if relevant address fields (Address Line 1, City, etc.) are present in Customer Info. If they are, it uses them.
  2. If the address fields are not in the Customer Info, the script attempts to fallback to the user’s Billing Address or Shipping Address (or the first available address).
  3. If no suitable data is found in those addresses, it moves on to any additional addresses.

Legacy Logic (Optional)

If you prefer how the script behaved before, you can revert to the old logic. In the old logic, the script always tried the billing address first, then any other addresses, and certain fields like first name, last name, and email always came from Customer Info.

Enabling Legacy Logic

If you open the script configuration (within the Scripts tab for your product), you’ll see or can add a JSON-style block:

json
{  "legacyMapping": true }

Setting legacyMapping to true reverts to the old approach.

Note: If legacyMapping is set to false or omitted, the new flow is used.

5. New Address Prefixes: billing_ and shipping_

We have added explicit prefixes so you can force certain fields to always use Billing or Shipping data without fallback. For example:

  • prepopulate_billing_addressline1
  • prepopulate_shipping_postalcode

Using these prefixes ensures the data comes only from that specific address type—if the data isn’t set in that address, it won’t try any other source.

6. Locating Selected Tags

  1. Select a text field in MegaEdit.
  2. Bring up the pop up menu and navigate to the Details tab.
  3. Locate the Tags field.
  4. Any previously selected tag (specified using the Prepopulate Data button) should appear in here. You can also manually amend the selected tag, such as with the shipping_ or billing_ options above.

7. Testing Your Setup

  1. Log in with a test user account that has complete profile information.
  2. Check that the data populates correctly:
    • If you’re using the new fallback logic (default), confirm that fields fill from the user’s Customer Info first, then billing/shipping if necessary.
    • If you’ve used a billing_ or shipping_ prefix, confirm those fields always pull from the chosen address and ignore other addresses.
  3. Log in as a different user (with different address details) to make sure everything is working as intended.

7. Final Tips

  • Admin vs. Customer View: You must be in a true “customer” login session to see real data. Admin “emulate user” sessions often do not reveal personal data fields.
  • Custom Fields: Make sure your custom fields are enabled in your store’s Customer Settings so they appear as an option to fill.
  • Troubleshooting: If any field is not populating, check the script contig or confirm your user’s profile actually has the data (e.g., a billing address with no “City” won’t populate “City”).
Incomplete
Alternate Search Terms
WYSIWYG stands for "What You See Is What You Get" which means that the styling choices made in this editor will be reflected on the front end.