本文整理汇总了PHP中MCAPI::campaignEcommAddOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP MCAPI::campaignEcommAddOrder方法的具体用法?PHP MCAPI::campaignEcommAddOrder怎么用?PHP MCAPI::campaignEcommAddOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCAPI
的用法示例。
在下文中一共展示了MCAPI::campaignEcommAddOrder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
function process()
{
if (!$this->valid_cfg) {
return;
}
global $order, $insert_id;
$OSCOM_Db = Registry::get('Db');
$orderId = $insert_id;
// just to make it obvious.
$debug_email = '';
if ($this->debug) {
$debug_email .= '------------[New Order ' . $orderId . ']-----------------' . "\n" . '$order =' . "\n" . print_r($order, true) . '$_COOKIE =' . "\n" . print_r($_COOKIE, true);
}
if (!isset($_COOKIE['mailchimp_campaign_id']) || !isset($_COOKIE['mailchimp_email_id'])) {
return;
}
if ($this->debug) {
$debug_email .= date('Y-m-d H:i:s') . ' current ids:' . "\n" . date('Y-m-d H:i:s') . ' eid =' . $_COOKIE['mailchimp_email_id'] . "\n" . date('Y-m-d H:i:s') . ' cid =' . $_COOKIE['mailchimp_campaign_id'] . "\n";
}
$Qorder = $OSCOM_Db->get('orders', 'orders_id', ['customers_id' => $_SESSION['customer_id']], 'date_purchased desc', 1);
$totals_array = array();
$Qtotals = $OSCOM_Db->get('orders_total', ['value', 'class'], ['orders_id' => $Qorder->valueInt('orders_id')]);
while ($Qtotals->fetch()) {
$totals_array[$Qtotals->value('class')] = $Qtotals->value('value');
}
$products_array = array();
$Qproducts = $OSCOM_Db->get('orders_products', ['products_id', 'products_model', 'products_name', 'products_tax', 'products_quantity', 'final_price'], ['orders_id' => $Qorder->valueInt('orders_id')]);
while ($Qproducts->fetch()) {
$products_array[] = array('id' => $Qproducts->valueInt('products_id'), 'name' => $Qproducts->value('products_name'), 'model' => $Qproducts->value('products_model'), 'qty' => $Qproducts->value('products_quantity'), 'final_price' => $Qproducts->value('final_price'));
$totals_array['ot_tax'] += $Qproducts->value('product_tax');
}
$mcorder = array('id' => $Qorder->valueInt('orders_id'), 'total' => $totals_array['ot_total'], 'shipping' => $totals_array['ot_shipping'], 'tax' => $totals_array['ot_tax'], 'items' => array(), 'store_id' => $this->store_id, 'store_name' => $_SERVER['SERVER_NAME'], 'campaign_id' => $_COOKIE['mailchimp_campaign_id'], 'email_id' => $_COOKIE['mailchimp_email_id'], 'plugin_id' => 1216);
foreach ($products_array as $product) {
$item = array();
$item['line_num'] = $line;
$item['product_id'] = $product['id'];
$item['product_name'] = $product['name'];
$item['sku'] = $product['model'];
$item['qty'] = $product['qty'];
$item['cost'] = $product['final_price'];
//All this to get a silly category name from here
$Qcat = $OSCOM_Db->get('products_to_categories', 'categories_id', ['products_id' => $product['id']], null, 1);
$cat_id = $Qcat->valueInt('categories_id');
$item['category_id'] = $cat_id;
$cat_name == '';
$continue = true;
while ($continue) {
//now recurse up the categories tree...
$Qcat = $OSCOM_Db->prepare('select c.categories_id, c.parent_id, cd.categories_name from :table_categories c inner join :table_categories_description cd on c.categories_id = cd.categories_id where c.categories_id = :categories_id');
$Qcat->bindInt(':categories_id', $cat_id);
$Qcat->execute();
if ($cat_name == '') {
$cat_name = $Qcat->value('categories_name');
} else {
$cat_name = $Qcat->value('categories_name') . ' - ' . $cat_name;
}
$cat_id = $Qcat->valueInt('parent_id');
if ($cat_id == 0) {
$continue = false;
}
}
$item['category_name'] = $cat_name;
$mcorder['items'][] = $item;
}
$GLOBALS["mc_api_key"] = $this->apikey;
$api = new MCAPI('notused', 'notused');
$res = $api->campaignEcommAddOrder($mcorder);
if ($api->errorMessage != '') {
if ($this->debug) {
$debug_email .= 'Error:' . "\n" . $api->errorMessage . "\n";
}
} else {
//nothing
}
// send!()
if ($this->debug && !empty($debug_email)) {
$debugEmail = new Mail(MODULE_HEADER_TAGS_MAILCHIMP_360_DEBUG_EMAIL, null, STORE_OWNER_EMAIL_ADDRESS, STORE_OWNER, 'MailChimp Debug E-Mail');
$debugEmail->setBody($debug_email);
$debugEmail->send();
}
}
示例2: process
function process()
{
if (!$this->valid_cfg) {
return;
}
global $order, $insert_id;
$orderId = $insert_id;
// just to make it obvious.
$debug_email = '';
if ($this->debug) {
$debug_email .= '------------[New Order ' . $orderId . ']-----------------' . "\n" . '$order =' . "\n" . print_r($order, true) . '$_COOKIE =' . "\n" . print_r($_COOKIE, true);
}
if (!isset($_COOKIE['mailchimp_campaign_id']) || !isset($_COOKIE['mailchimp_email_id'])) {
return;
}
if ($this->debug) {
$debug_email .= date('Y-m-d H:i:s') . ' current ids:' . "\n" . date('Y-m-d H:i:s') . ' eid =' . $_COOKIE['mailchimp_email_id'] . "\n" . date('Y-m-d H:i:s') . ' cid =' . $_COOKIE['mailchimp_campaign_id'] . "\n";
}
$customer_id = $_SESSION['customer_id'];
$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int) $customer_id . "' order by date_purchased desc limit 1");
$orders = tep_db_fetch_array($orders_query);
$totals_array = array();
$totals_query = tep_db_query("select value, class from " . TABLE_ORDERS_TOTAL . " where orders_id = " . (int) $orders['orders_id']);
while ($totals = tep_db_fetch_array($totals_query)) {
$totals_array[$totals['class']] = $totals['value'];
}
$products_array = array();
$products_query = tep_db_query("select products_id, products_model, products_name, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = " . (int) $orders['orders_id']);
while ($products = tep_db_fetch_array($products_query)) {
$products_array[] = array('id' => $products['products_id'], 'name' => $products['products_name'], 'model' => $products['products_model'], 'qty' => $products['products_quantity'], 'final_price' => $products['final_price']);
$totals_array['ot_tax'] += $products['product_tax'];
}
$mcorder = array('id' => $orders['orders_id'], 'total' => $totals_array['ot_total'], 'shipping' => $totals_array['ot_shipping'], 'tax' => $totals_array['ot_tax'], 'items' => array(), 'store_id' => $this->store_id, 'store_name' => $_SERVER['SERVER_NAME'], 'campaign_id' => $_COOKIE['mailchimp_campaign_id'], 'email_id' => $_COOKIE['mailchimp_email_id'], 'plugin_id' => 1216);
foreach ($products_array as $product) {
$item = array();
$item['line_num'] = $line;
$item['product_id'] = $product['id'];
$item['product_name'] = $product['name'];
$item['sku'] = $product['model'];
$item['qty'] = $product['qty'];
$item['cost'] = $product['final_price'];
//All this to get a silly category name from here
$cat_qry = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = " . (int) $product['id'] . " limit 1");
$cats = tep_db_fetch_array($cat_qry);
$cat_id = $cats['categories_id'];
$item['category_id'] = $cat_id;
$cat_name == '';
$continue = true;
while ($continue) {
//now recurse up the categories tree...
$cat_qry = tep_db_query("select c.categories_id, c.parent_id, cd.categories_name from " . TABLE_CATEGORIES . " c inner join " . TABLE_CATEGORIES_DESCRIPTION . " cd on c.categories_id = cd.categories_id where c.categories_id =" . $cat_id);
$cats = tep_db_fetch_array($cat_qry);
if ($cat_name == '') {
$cat_name = $cats['categories_name'];
} else {
$cat_name = $cats['categories_name'] . ' - ' . $cat_name;
}
$cat_id = $cats['parent_id'];
if ($cat_id == 0) {
$continue = false;
}
}
$item['category_name'] = $cat_name;
$mcorder['items'][] = $item;
}
$GLOBALS["mc_api_key"] = $this->apikey;
$api = new MCAPI('notused', 'notused');
$res = $api->campaignEcommAddOrder($mcorder);
if ($api->errorMessage != '') {
if ($this->debug) {
$debug_email .= 'Error:' . "\n" . $api->errorMessage . "\n";
}
} else {
//nothing
}
// send!()
if ($this->debug && !empty($debug_email)) {
tep_mail('', MODULE_HEADER_TAGS_MAILCHIMP_360_DEBUG_EMAIL, 'MailChimp Debug E-Mail', $debug_email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
}
}