久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Woocommerce 的訂單接收頁面上的 JS 跟蹤代碼中訂

Order items in a JS tracking code on Order received page in Woocommerce(在 Woocommerce 的訂單接收頁面上的 JS 跟蹤代碼中訂購商品)
本文介紹了在 Woocommerce 的訂單接收頁面上的 JS 跟蹤代碼中訂購商品的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在嘗試在 Woocommerce 感謝頁面中集成跟蹤代碼.我只找到了要填寫的訂單 ID.但我不知道如何為訂單商品數(shù)據(jù)完成此操作.

I am trying to integrate a tracking code in Woocommerce Thankyou page. I found just the order id to fill it out. But I don't know how to complete this for order items data.

這是我的實際代碼:

<script type="text/javascript">
ADMITAD = window.ADMITAD || {};

ADMITAD.Invoice = ADMITAD.Invoice || {};

ADMITAD.Invoice.broker = "adm";     // deduplication parameter (for Admitad by default)

ADMITAD.Invoice.category = "1";     // action code (defined during integration)


var orderedItem = [];               // temporary array for product items


// repeat for every product item in the cart

orderedItem.push({

  Product: {

  productID: 'product_id', // internal product ID (not more than 100 characters, the same as in your product feed)

  category: '1',               // tariff code (defined during integration)

  price: 'price',          // product price

  priceCurrency: "RON",        // currency code in the ISO-4217 alfa-3 format

 },

 orderQuantity: '{{quantity}}',   // product quantity

 additionalType: "sale"           // always sale

 });


ADMITAD.Invoice.referencesOrder = ADMITAD.Invoice.referencesOrder || [];
// adding items to the order

ADMITAD.Invoice.referencesOrder.push({

  orderNumber: "<?php echo $order->get_id(); ?>;", // internal order ID (not more than 100 characters)

  orderedItem: orderedItem

});

// Important! If order data is loaded via AJAX, uncomment this string. 

// ADMITAD.Tracking.processPositions();

</script>

感謝任何幫助.

推薦答案

以下重新訪問的代碼添加了正確的訂單項循環(huán)并使用了Order received"頁面(Thankyou)專用的動作鉤子:>

The following revisited code adds the correct order items loop and uses "Order received" page (Thankyou) dedicated action hook:

add_action( 'woocommerce_thankyou', 'js_tracking_thank_you_page', 90, 1 );
function js_tracking_thank_you_page( $order_id ) {
    // Get the WC_Order instance Object
    $order = wc_get_order( $order_id );

    // Output
    ?>
    <script type="text/javascript">
    ADMITAD = window.ADMITAD || {};

    ADMITAD.Invoice = ADMITAD.Invoice || {};

    // deduplication parameter (for Admitad by default)
    ADMITAD.Invoice.broker = "adm";

    // action code (defined during integration)
    ADMITAD.Invoice.category = "1";

    // temporary array for product items
    var orderedItem = [];

    <?php
    // Loop through Order items
    foreach( $order->get_items() as $item ) :
        $product = $item->get_product();
    ?>
    orderedItem.push({

      Product: {
        // internal product ID (not more than 100 characters, the same as in your product feed)
        productID: '<?php echo $item->get_product_id(); ?>',

        // tariff code (defined during integration)
        category: '1',

        // product price
        price: '<?php echo $product->get_price(); ?>',

        // currency code in the ISO-4217 alfa-3 format
        priceCurrency: '<?php echo $order->get_currency(); ?>',
      },
      // product quantity
      orderQuantity: '<?php echo $item->get_quantity(); ?>',

      additionalType: "sale" // always sale

    });
    <?php endforeach; // End of Loop ?>

    // adding items to the order
    ADMITAD.Invoice.referencesOrder = ADMITAD.Invoice.referencesOrder || [];

    ADMITAD.Invoice.referencesOrder.push({
      // internal order ID (not more than 100 characters)
      orderNumber: "<?php echo $order->get_id(); ?>;",

      orderedItem: orderedItem

    });

    // Important! If order data is loaded via AJAX, uncomment this string.
    // ADMITAD.Tracking.processPositions();
    </script>
    <?php
}

它應(yīng)該可以(已測試).

相關(guān):

  • 如何獲取 WooCommerce 訂單詳情
  • 獲取訂單商品和 Woocommerce 3 中的 WC_Order_Item_Product

添加 - 實時貨幣換算

1) 安裝并激活這個免費插件:Euro FxRef Currency Converter

1) Install and active this free plugin: Euro FxRef Currency Converter

2) 啟用從RON"到EUR"的自動貨幣轉(zhuǎn)換(產(chǎn)品價格示例).

2) Enable auto currency conversion from 'RON' to 'EUR' (product price example).

替換:

// product price
price: '<?php echo $product->get_price(); ?>',

通過以下:

// Converted product price (rounded with 2 decimals)
<?php $price = EuroFxRef::convert( $product->get_price(), 'RON', 'EUR' ); ?>
price: '<?php echo round( $price, 2 );  ?>',

經(jīng)過測試并有效……這應(yīng)該可以解決問題.

Tested and works… This should do the trick.

這篇關(guān)于在 Woocommerce 的訂單接收頁面上的 JS 跟蹤代碼中訂購商品的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產(chǎn)品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產(chǎn)品的總訂單數(shù))
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產(chǎn)品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結(jié)帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 天天噜天天干 | 麻豆精品一区二区三区在线观看 | 精品综合久久久 | 日韩中文在线视频 | 国产精品久久久久久久久大全 | 久久亚洲欧美日韩精品专区 | 在线视频中文字幕 | 亚洲自拍偷拍免费视频 | 久久久黄色 | 日韩午夜| 亚洲福利免费 | 91亚洲精品久久久电影 | 久久激情视频 | 欧美乱淫视频 | va在线 | 91精品综合久久久久久五月天 | 久久69精品久久久久久久电影好 | 日日草夜夜草 | 草久久| 天天干视频 | 91综合在线观看 | 先锋资源站 | 一区二区三区av | 日韩亚洲视频 | 久久久久久久久久久久一区二区 | 国产午夜精品久久久久免费视高清 | 亚洲第一天堂 | 欧美视频三级 | 国产欧美一区二区三区日本久久久 | 在线第一页 | 黄色精品 | 日韩一区在线播放 | 97人人澡人人爽91综合色 | 国产精品久久久久久久久久免费看 | 亚洲成人国产综合 | 欧美日韩国产中文 | 欧美天堂 | 久久这里只有精品首页 | 欧美在线观看免费观看视频 | 综合激情久久 | 日日干天天操 |