Zen Cart Logo
Forums / Managing Customers and Orders / Need Snail Mail List

Need Snail Mail List

Locked

Views: 1,032

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
14 Feb 2010, 8:01 PM
#1
tat2nu avatar

tat2nu

Zen Follower

Join Date:
Jan 2005
Posts:
178
Plugin Contributions:
0

Need Snail Mail List

I am wanting to occasionally mail special flyers to customers and can not figure out how to export the most current customer addresses. I tried exporting the address book in CSV format from MyPhpAdmin but it does not give me the state or county. Just the codes. I really do not want to have to manually enter thousands of addresses for a mailing.

Thanks,
Marc

14 Feb 2010, 9:10 PM
#2
llynix avatar

llynix

Zen Follower

Join Date:
Jul 2009
Location:
Texas
Posts:
210
Plugin Contributions:
0

Re: Need Snail Mail List

Here's my query to get all US deliverable addresses.

SELECT CONCAT( c.customers_firstname, " ", c.customers_lastname ) AS FullName, ab.entry_street_address AS Address1, ab.entry_suburb AS Address2, ab.entry_postcode AS ZipPostalCode, ab.entry_city AS City, sa.abbrev AS StateAB
FROM cart1_customers c, cart1_address_book ab
LEFT JOIN cart1_zones z ON ( ab.entry_zone_id = z.zone_id
AND ab.entry_country_id = z.zone_country_id )
LEFT JOIN cart1_countries co ON ab.entry_country_id = co.countries_id
LEFT JOIN mailing_lists.stateabbrev sa ON IF(ISNULL(z.zone_name), co.countries_name, z.zone_name ) = sa.name
WHERE ab.customers_id = c.customers_id
AND ab.address_book_id = c.customers_default_address_id
AND (
co.countries_name = 'Guam' OR
co.countries_name = 'Puerto Rico' OR
co.countries_name = 'Virgin Islands (U.S.)' OR
co.countries_name = 'American Samoa' OR
co.countries_name = 'Marshall Islands' OR
co.countries_name = 'Micronesia, Federated States of' OR
co.countries_name = 'Northern Mariana Islands' OR
co.countries_name = 'Palau' OR
co.countries_name = 'United States')