我們正在創建一個專業購物車,當我們的客戶進行購買時,它會在購買時在數據庫中記錄會員編號。我創建了以下代碼以使用Post Affiliate Pro API獲取聯盟ID /名稱。Zen Post Cart更新數據庫與Post會員專業編號
include ("affiliate/api/PapApi.class.php");
$session = new Gpf_Api_Session("https://www.elitespecialtymeats.com/affiliate/scripts/server.php");
if(!$session->login("user", "password")){ die("Cannot login. Message: ".$session->getMessage()); }
$clickTracker = new Pap_Api_ClickTracker($session);
try {
$clickTracker->track();
$clickTracker->saveCookies();
if ($clickTracker->getAffiliate() != null){ $affid=$clickTracker->getAffiliate()->getValue('username'); }
else{ $affid=''; }
}catch (Exception $e){
$affid='';
}
我試圖找出將該ID添加到購買中的最佳方法。我認爲最好將它添加到tpl_checkout_success_default.php中,在那裏他們將購買日誌記錄到PAP中。我的問題是,我對系統實施代碼不夠了解。
我最好的猜測是
$db->Execute("UPDATE ".TABLE_ORDERS_TOTAL." SET affid='$affid' where orders_id = '".(int)$orders->fields['orders_id']."' AND class in ('ot_coupon', 'ot_gv', 'ot_subtotal', 'ot_group_pricing', 'ot_quantity_discount')");
將這項工作或將我擺烏龍?