Hi folks,
I have the checkout pane for opting in to a newsletter working fine, but am having a little trouble "grabbing" the address/email variables to pass to my newsletter management software via curl. What am I missing? Thanks in advance:
<?php
// $Id$
/**
* @file
* Defines a checkout pane that lets customers opt-in to receive an email newsletter
* When you install this module, you should go to the Checkout panes settings
* page and add newsletter opt-in options to appear during checkout.
*/
/*******************************************************************************
* Hook Functions (Ubercart)
******************************************************************************/
/**
* Implementation of hook_checkout_pane().
*/
function uc_newsletter_checkout_pane() {
$panes[] = array(
'id' => 'newsletter',
'callback' => 'uc_checkout_pane_newsletter',
'title' => t('Stay in Touch'),
'desc' => t('Join our e-newsletter list to stay informed about specials and promotions. We promise never to sell, rent or give away your personal information.'),
'weight' => 8,
);
return $panes;
}
/**
* Implementation of hook_order().
*/
function uc_newsletter_order($op, &$arg1, $arg2) {
switch ($op) {
case 'submit':
if ($arg1->newsletter['opt_in'] == 1) {
$postvars = array(
'fields_email'=>$arg1->customer['primary_email'],
'fields_fname'=>$arg1->billing['billing_first_name'],
'fields_lname'=>$arg1->billing['billing_last_name'],
'fields_address1'=>$arg1->billing['billing_street1'],
'fields_address2'=>$arg1->billing['billing_street2'],
'fields_city'=>$arg1->billing['billing_city'],
'fields_state'=>$arg1->billing['billing_zone'],
'fields_zip'=>$arg1->billing['billing_postal_code'],
'fields_phone'=>$arg1->billing['billing_phone'],
'listid'=>9907524,
'specialid:3388'=>'JICV',
'clientid'=>190495,
'realistid'=>1,
'doubleopt'=>0,
);
$url = 'http://app.intellicontact.com/icp/signup.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
$result = curl_exec($ch);
if (curl_errno($ch)) {
$result = curl_error($ch);
}
curl_close($ch);
}
}
}
/*******************************************************************************
* Callback Functions, Forms, and Tables
******************************************************************************/
function uc_checkout_pane_newsletter($op, &$arg1, $arg2) {
switch ($op) {
case 'view':
$description = t('Would you like to recieve promotions and special offers from Desert Sun? Sign up to receive our e-newsletter!');
$contents['opt_in'] = array(
'#type' => 'checkboxes',
'#title' => t('Check the box below to opt in.'),
'#options' => array(
'1' => t('Subscribe Me'),
),
'#default_value' => $arg1->newsletter['opt_in'],
);
return array(
'description' => $description,
'contents' => $contents,
);
case 'process':
$arg1->newsletter['opt_in'] = $arg2['opt_in'];
return TRUE;
}
}



Joined: 12/09/2007