2012-10-23 44 views
0

我們正在創建一個專業購物車,當我們的客戶進行購買時,它會在購買時在數據庫中記錄會員編號。我創建了以下代碼以使用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')"); 

將這項工作或將我擺烏龍?

回答

0

首先,使用API​​您正在加載會員用戶名(... getValue('username')),而不是您在第一段中所述的會員ID。你應該使用getValue('userid'); (用於會員ID)或getValue('refid'); (用於推薦ID)。

您嘗試使用的數據庫命令僅適用於表TABLE_ORDERS_TOTAL具有名爲'affid'的列的情況。你可以手動將它添加到表...

我想知道你爲什麼要做這樣的事情......看起來好像你想稍後使用該ID作爲一些特殊用途。您是否想向原始轉介人提供佣金,即使客戶移除了所有的Cookie或同時點擊了另一個附屬公司的橫幅廣告?如果是這樣,您應該使用終身佣金: http://support.qualityunit.com/541587-Lifetime-commissions

如果您需要任何其他幫助,請隨時聯繫我們的在線支持。

0

您可能想看看JROX的做法 - 它們是Zen Cart中流行的聯盟營銷系統。它在這裏描述:http://jam.jrox.com/docs/index.php?article=111

基本上,他們只是搭載到結帳成功頁面,並將其邏輯粘在頁腳中。