示例#1
0
	/**
	* Examine order contents stored in subscription data to see if it contains a specific product.
	*
	* @param Interspire_EmailIntegration_Subscription_Order $subscription
	* @param int $productId
	*/
	public function qualifyOrderProduct(Interspire_EmailIntegration_Subscription_Order $subscription, $productId)
	{
		return $subscription->containsProduct($productId);
	}
示例#2
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();
		}
	}
}
示例#3
0
	protected function _performOrderExport()
	{
		if (!empty($this->_search)) {
			// there are search parameters, use them to filter customer data before exporting
			/** @var ISC_ADMIN_ORDERS */
			$orderClass = GetClass('ISC_ADMIN_ORDERS');
			$search = $orderClass->BuildWhereFromVars($this->_search);

			$where = ' WHERE 1=1 ' . $search['query'] . ' ';
			$join = $search['join'];

			unset($search);
		}
		else
		{
			$where = '';
			$join = '';
		}

		$query = 'SELECT /* Job_EmailIntegration_ModuleExport->_performOrderExport */ /*:columns*/ FROM `[|PREFIX|]orders` ' . $join . ' ' . $where;

		if (!$this->_skip) {
			$count = $this->_db->FetchOne(str_replace('/*:columns*/', 'COUNT(*)', $query));
			$this->_log->LogSystemNotice(array('emailintegration', $this->_module->GetName()), GetLang('EmailIntegration_Log_JobCommencingOrderExport', array(
				'count' => $count,
			)));
			$this->_keystore->set($this->_prefix . 'estimate', $count);
		}

		// no matter what the search specified, always order by id so new customers do not mess up the batch logic
		$query .= ' ORDER BY `orderid` LIMIT ';

		if ($this->_skip) {
			$query .= $this->_skip . ',';
		}

		$query .= self::BATCH_SIZE;

		$query = $this->_db->Query(str_replace('/*:columns*/', '`orderid`', $query));
		if (!$query) {
			$error = GetLang('EmailIntegration_Log_JobOrderDatabaseError');
			$this->_logError($error);
			$this->_errorExport($error);
			return false;
		}

		$batch = array();
		while ($row = $this->_db->Fetch($query))
		{
			$subscription = new Interspire_EmailIntegration_Subscription_Order($row['orderid']);
			$subscription->setDoubleOptIn($this->_doubleOptin);
			$subscription->setUpdateExisting($this->_updateExisting);
			$batch[] = $subscription;
		}
		unset($subscription);

		if (!empty($batch)) {
			$this->_logDebug('batch subscribing ' . count($batch) . ' orders');
			$this->_subscribeBatch($batch);
		}

		return count($batch);
	}
示例#4
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();
	}
	/**
	* Handle request from settings UI for a field sync form
	*
	* @param mixed $auth
	* @param mixed $data
	* @return mixed
	*/
	public function remoteGetFieldSyncForm($auth, $data)
	{
		$template = Interspire_Template::getInstance('admin');

		$listId = $data['listId'];

		if (isset($data['modalContentOnly'])) {
			$modalContentOnly = (bool)$data['modalContentOnly'];
		} else {
			$modalContentOnly = false;
		}

		$lists = $this->getLists(); // use this to force a refresh from provider if necessary

		foreach ($lists as $list) {
			if ($list['provider_list_id'] == $listId) {
				$listFields = $this->getListFields($listId);

				$template->assign('listFields', $listFields);

				/** @var ISC_FORM */
				$form = $GLOBALS['ISC_CLASS_FORM'];

				if (isset($data['subscriptionType'])) {
					$subscription = 'Interspire_EmailIntegration_Subscription_' . $data['subscriptionType'];
					$subscription = new $subscription();
				}
				else
				{
					$subscription = new Interspire_EmailIntegration_Subscription_Order();
				}

				$mappings = array();

				if (isset($data['map']) && $data['map']) {
					$map = ISC_JSON::decode($data['map'], true);
					if (is_array($map)) {
						foreach ($map as $provider => $local) {
							$mappings[$provider] = $local;
						}
					}
				}

				$formFields = $subscription->getSubscriptionFields();
				$template->assign('formFields', $formFields);

				$template->assign('module', $this);
				$template->assign('mappings', $mappings);
				break;
			}
		}

		if ($modalContentOnly) {
			return array(
				'success' => true,
				'html' => $template->render('emailintegration.fieldsyncform.modalcontent.tpl'),
			);
		} else {
			$template->display('settings.emailintegration.fieldsyncform.tpl');
			die();
		}
	}