Example #1
0
/**
*	Do we need to subscribe the customer to either of our mailing lists?
*	If they ticked yes then the appropriate cookies were set before they
*	chose their shipping provider and entered their payment details
*/
function SubscribeCustomerToLists($pendingOrderToken)
{
	$orders = LoadPendingOrdersByToken($pendingOrderToken);
	$order = current($orders['orders']);
	$email = $order['ordbillemail'];
	$firstName = $order['ordbillfirstname'];

	foreach($orders['orders'] as $order) {
		$extraInfo =array();
		if(isset($order['extrainfo']) && $order['extrainfo'] != '') {
			$extraInfo = @unserialize($order['extrainfo']);
		}

		$format = Interspire_EmailIntegration_Subscription::FORMAT_PREF_NONE;
		if (isset($extraInfo['mail_format_preference'])) {
			$format = (int)$extraInfo['mail_format_preference'];
		}

		// Should we add them to our newsletter mailing list?
		if(isset($extraInfo['join_mailing_list']) && $extraInfo['join_mailing_list'] == 1) {
			$subscription = new Interspire_EmailIntegration_Subscription_Newsletter($email, $firstName);
			$subscription->setDoubleOptIn(GetConfig('EmailIntegrationOrderDoubleOptin')); // override newsletter double-opt-in preference with order double-opt-in preference when subscribing someone to newsletter list through the checkout
			$subscription->setSendWelcome(GetConfig('EmailIntegrationOrderSendWelcome')); // as above
			$subscription->setEmailFormatPreference($format);
			$subscription->routeSubscription();
		}

		// Should we add them to our special offers & discounts mailing list?
		if(isset($extraInfo['join_order_list']) && $extraInfo['join_order_list']) {
			$subscription = new Interspire_EmailIntegration_Subscription_Order($order['orderid']);
			$subscription->setEmailFormatPreference($format);
			$subscription->routeSubscription();
		}
	}
}
Example #2
0
	/**
	 * Subscribe a customer to any other lists based on their order if they have opted in to them
	 *
	 * @param array $orderRow An array that is ready to be passed to CreateOrder()
	 *
	 * @return void
	 */
	public function SubscribeCustomerToOtherLists($orderRow)
	{
		// If the customer didn't opt in, stop immediately
		if ($this->response->data['new-order-notification']['buyer-marketing-preferences']['email-allowed']['VALUE'] != 'true') {
			return;
		}

		$subscription = new Interspire_EmailIntegration_Subscription_Order($orderRow['orderid']);
		$subscription->routeSubscription();
	}