FROM CACHE - jp_header

注文状況ページに「商品ID」「数量」「単価」を出力したい

解決済
STUN
新規メンバー
2 0 0

はじめまして。

この度、注文状況ページにアフィリエイト計測タグを挿入したいのですが、

商品ID(.../products/〇〇〇の部分)
数量
単価(税込)

を出力したいのですが、うまくいきません。

コードは以下のような感じです。
【商品ID】【数量】【単価】にはそれぞれ、どのようなタグを挿入すれば良いでしょうか?

詳しい方いらっしゃいましたら、ご教授いただけますと大変助かります。

よろしくお願いいたします。

<script>
if (!window.dtlpcvCvConf) {
  window.dtlpcvCvConf = [];
}
window.dtlpcvCvConf.push({
  siteId: "",
  commitData: {
    pid: "",
    amount: "",
    mid: "",
    u: "{{order_number}}", 
    t:"",
    cvinfo:"【商品ID】.【数量】.【単価】:【商品ID】.【数量】.【単価】:・・・" ← こんな感じで、ここに購入商品分をループ出力したいです。
    }
});
</script>
<script src="" async="async"></script>

 

1 件の受理された解決策
YosukeOshima
新規メンバー
1 1 1

成功

for文を使うことで繰り返し商品の情報を出力することができます。

添付していただいているコードを書き換えると以下のような形になります。

line_itemsを一つずつ取り出してproduct_id, quantity, line_item_final_priceを出力しています。

おそらく最後のline_itemsの後にはコロンは不要だと思いますので、if文を使って出力しないようにしています。

<script>
if (!window.dtlpcvCvConf) {
  window.dtlpcvCvConf = [];
}
window.dtlpcvCvConf.push({
  siteId: "",
  commitData: {
    pid: "",
    amount: "",
    mid: "",
    u: "{{order_number}}", 
    t:"",
    cvinfo: "{% for line_item in line_items %}{{ line_item.product_id }}.{{ line_item.quantity }}.{{ line_item.final_price | money_without_currency }}{% if forloop.last == false %}:{% endif %}{% endfor %}"
    }
});
</script>
<script src="" async="async"></script>

 

元の投稿で解決策を見る

2件の返信2
YosukeOshima
新規メンバー
1 1 1

成功

for文を使うことで繰り返し商品の情報を出力することができます。

添付していただいているコードを書き換えると以下のような形になります。

line_itemsを一つずつ取り出してproduct_id, quantity, line_item_final_priceを出力しています。

おそらく最後のline_itemsの後にはコロンは不要だと思いますので、if文を使って出力しないようにしています。

<script>
if (!window.dtlpcvCvConf) {
  window.dtlpcvCvConf = [];
}
window.dtlpcvCvConf.push({
  siteId: "",
  commitData: {
    pid: "",
    amount: "",
    mid: "",
    u: "{{order_number}}", 
    t:"",
    cvinfo: "{% for line_item in line_items %}{{ line_item.product_id }}.{{ line_item.quantity }}.{{ line_item.final_price | money_without_currency }}{% if forloop.last == false %}:{% endif %}{% endfor %}"
    }
});
</script>
<script src="" async="async"></script>

 

STUN
新規メンバー
2 0 0

ありがとうございます!