---- dataentry ----
type : integration # do not change this line
systems : ConstantContact.
name : Add customers to mailing list.
description : Allow customers to 'opt in' to your Constant Contact mailing list during checkout.
tags : mailing list, emarketing
date_dt : 2008-05-21
version : 1
developer_url : http://themancan.com
----
====== ConstantContact ======
fc-constantcontact.php
Included for good measure are a PHP4-compatible XML parser, RC4 decryption library, and test harness.
- Upload all 4(!) files to a folder your web server. Customize this block at the top of fc-constantcontact.php:
// ...
$ConstantContact_Auth = array(
'user' => 'username', // Replace "username" with your Constant Contact username
'pass' => 'password' // Replace "password" with your Constant Contact password
);
$ListName = 'My Awesome List!'; // The exact name of your list in Constant Contact.
/**
* Use a custom field during checkout? If true, check for the presence of $Custom_Field below.
* If false, always subscribe the customer. Use wisely.
*/
$Use_Custom_Field = true;
$Custom_Field = 'Subscribe'; // Name of the custom "Opt In" field during checkout.
$Custom_Field_Value = 'yes'; // The value of the custom field that indicates the customer's agreement.
$key = 'CHANGE THIS TEXT to your own datafeed api key'; // Make up something random and 30+ characters. This is the encryption key that your XML is encrypted using, and you'll use it below as well.
// ...
- Point FoxyCart to http://www.your-domain.com/path/to/fc-constantcontact.php
- Log into your FoxyCart admin and go to Store -> advanced.
- Check the checkbox to turn the datafeed on, enter a SUPER SECRET datafeed key and copy it to your configuration.
- Enter the URL to ''fc-constantcontact.php'' (e.g. ''http://your.domain.dom/path/to/fc-constantcontact.php'') that you uploaded as described above.
- Save your settings.
- TEST! It should work, but give it a test transaction to make sure. Enter your datafeed key and the URL of your ''fc-constantcontact.php'' into ''test.xmldatafeed.php'', then open ''http://your.domain.dom/path/to/test.xmldatafeed.php'' in your browser. You should get a page that contains only the word ''foxy'' in reply. If you get something else, double-check your datafeed keys in both files and, if all else fails, pop on by the forums.
- Don't panic. You're done!
===== The "Subscribe" Checkbox =====
==== FoxyCart 2.0+ ====
If your store is on FoxyCart 2.0 or newer, a new template configuration option will automatically insert a newsletter subscribe checkbox as part of the checkout form. To enable that, simply navigate to your store's FoxyCart administration, and on the "configuration" page, enable the "Allow users to sign up for your newsletter" option.
Within the ''fc-constantcontact.php'' file - you'll need to update the ''$Custom_Field'' variable to be set to ''newsletter_subscribe'', and the ''$Custom_Field_Value'' to ''1'' like this:
$Custom_Field = 'newsletter_subscribe'; // Name of the custom "Opt In" field during checkout.
$Custom_Field_Value = '1'; // The value of the custom field that indicates the customer's agreement.
==== FoxyCart 1.1 and older ====
Now you have a datafeed receiver all set up on your server, so it's time to let your customers opt in to your mailing list. To do that, we need to add a [[:v:1.1:docs:checkout|Custom Field]] to your checkout template, so that your customer sees a "Subscribe" checkbox alongside their cart contents. There are a lot of cool things possible custom fields; find out more at [[:v:1.1:checkout|the wiki page on Custom Fields]]. Today we're only going to add a single checkbox to the checkout template. Open the template up in your editor (if it's hosted on your server) or edit it directly from the FoxyCart admin interface, and add the following block of code anywhere in the template:
^^custom_begin^^
You can put the code at the end of the file, or at the beginning -- it doesn't matter. FoxyCart will move the ''Newsletter
^^custom_end^^