2016-05-19 2 views
1

を注文するトラッキングコードを追加することwoocommerce - 。私はアフィリエイトプログラム委員会ジャンクションから追跡を統合することを探していますページ(コミッションジャンクションアフィリエイトプログラム

彼らは私のために受信したページに追加するには、次のサンプルコードを私に提供してきました私は絶対に失われています、いくつかの同様のプログラムのためのプラグインがあります。

(彼らはjavascriptとASPを提供しています物事のルックスによって代替それは場合に役立ちます)

<!-- BEGIN COMMISSION JUNCTION TRACKING CODE --> 

<iframe height="1" width="1" frameborder="0" scrolling="no"   src="https://www.emjcd.com/tags/c?containerTagId=14209&ITEMx=[ItemSku]&AMTx= [AmountofItem]&QTYx=[Quantity]&CID=1529328&OID=[OID]&TYPE=385769&AMOUNT=[Subtotal]&DISCOUNT=[DiscountAmount]&CURRENCY=[CURRENCY]&COUPON=[couponcode]" name="cj_conversion" ></iframe> 

<!-- END COMMISSION JUNCTION TRACKING CODE --> 

答えて

0

あなたのテーマに次のコードを追加のfunctions.phpファイル

トラッキングコードを見てみると
add_action('woocommerce_thankyou', 'my_custom_tracking'); 

function my_custom_tracking($order_id) { 

    global $woocommerce; 

    $order = wc_get_order($order_id); 
    $total = $order->get_total(); 
    $currency = get_woocommerce_currency(); 

    $coupons = $order->get_used_coupons(); 

    $coupon_code = ''; 

    foreach ($coupons as $coupon){ 
     $coupon_code = $coupon; 
    } 

    $discount = $order->get_total_discount(); 

    $tracking = '<iframe height="1" width="1" frameborder="0" scrolling="no" src="https://www.emjcd.com/tags/c?containerTagId=14209&ITEMx=[ItemSku]&AMTx=[AmountofItem]&QTYx=[Quantity]&CID=1529328&OID=[OID]&TYPE=385769&AMOUNT='. $total .'&DISCOUNT='. $discount .'&CURRENCY='. $currency .'&COUPON='. $coupon_code .'" name="cj_conversion" ></iframe>'; 
    echo $tracking; 

    } 

、私たちは正しい値とSRCのURLを入力する必要があり推測を持っています。しかし、私は確信していません。あなたはのSKUのすべてをリストする必要があります

+0

正しい、私は...など、私が質問に注文のwoocommerce詳細を追加する必要があるという仮定(SKU、Amountofアイテム、数量、クーポン、下の私のためにめちゃくちゃ混乱だ。 –

+0

こんにちは、私は答えを更新しました、注文総額、通貨、使用済みクーポンコード、割引額などを管理しました。 私はitemSkuを含めることができませんでした/アイテム/数量のために、自分のすることができ、複数の製品を引き起こします。 @MashR。 –

+0

なぜforループを実行せず、順番に製品間で繰り返すのでしょうか? – jonaz

0

は、その価格と一緒に購入しました。必要であれば、あなたはすでにあなたがiframe内に入れ価格の値引きを控除している場合を除き、注文にドルの割引を適用するDISCOUNTパラメータを使用することができます。クーポンコードも有益です。あなたはJavaScriptでこれを行うと、ご注文データは、ここで以下のダミーデータのように見えるオブジェクトの配列であると仮定したい場合は

は、JavaScriptでそれを行うだろう方法は次のとおりです。

// Some dummy data (populate real data in your code) 
 
var order = { 
 
\t id: "AB12345", 
 
\t subtotal: "200.00", 
 
\t discount: "10.00", 
 
\t coupon: "DEAL10", 
 
\t items: [ 
 
\t \t { sku: "FOO123", price: "75.00", quantity: 2 }, 
 
\t \t { sku: "BAR234", price: "50.00", quantity: 1 } 
 
\t ] 
 
}; 
 

 
// The actual code 
 
var cj = { 
 
\t tagId: 14209, 
 
\t cid: 1529328, 
 
\t type: 385769 
 
}; 
 
var cjString = "https://www.emjcd.com/tags/c?containerTagId=" + cj.tagId + "&"; 
 

 
for (i=0; i<order.items.length; i++) { 
 
    cjString += "ITEM" + i + "=" order.items[i].sku + "AMT" + i + order.items[i].price + "QTY" + i + order.items[i].quantity + "&"; 
 
} 
 

 
cjString += "CID=" + cj.cid + "&OID=" + order.id + "&TYPE=" + cj.type + "&AMOUNT=" + order.subtotal + (discount.length ? "&DISCOUNT=" + order.discount : "") + "&CURRENCY=USD" + (coupon.length ? "&COUPON=" + order.coupon : ""); 
 

 
// Now we put it all together and insert into the page 
 
var frame = document.createElement("iframe"); 
 
frame.name = "cj_conversion"; 
 
frame.height = 1; 
 
frame.width = 1; 
 
frame.frameBorder = 0; 
 
frame.scrolling = "no"; 
 
frame.src = cjString; 
 
document.body.insertBefore(frame, document.body.childNodes[0]);

関連する問題