0
使用下面引用的優秀資源和有用的評論我已經構建了一個Wordpress插件(按代碼)將WooCommerce交易數據發送到自定義CRM。從感謝頁面。WooCommerce:自定義電子商務跟蹤 - 幾乎有
但是我卡住了。我可以把交易價值,稅款和運費的細節,但我似乎不能打電話,或發:
一)產品名稱
二)產品類別
C)產品編號
d)之間的產品拆分的詳細信息多個產品
任何想法,鏈接或建議非常感謝。這是新的,並試圖通過戰鬥。
<?php
/**
* Plugin Name: eCommerce Tracking
* Plugin URI:
* Description: Send shopping data to CRM
* Version: 1.0
* Author: fly
* Author URI:
* License: GPL2
*/
add_action('woocommerce_thankyou', 'my_custom_tracking');
function my_custom_tracking($order_id) {
// Lets grab the order
$order = new WC_Order($order_id);
// Order ID
$order_id = $order->get_order_number();
// Order total
$order_total = $order->get_total();
// Order e-mail
$order_email = $order->billing_email;
// Order Billing First Name
$order_fname = $order->billing_first_name;
// Order Billing Last Name
$order_lname = $order->billing_last_name;
// Order Billing Address 1
$order_bill1 = $order->billing_address_1;
// Order Billing Address 2
$order_bill2 = $order->billing_address_2;
// Billing City
$order_billcity = $order->billing_city;
// Billing State
$order_billstate = $order->billing_state;
// Billing Postcode
$order_billpostcode = $order->billing_postcode;
// Billing Country
$order_billcountry = $order->billing_country;
// Billing Phone
$order_billphone = $order->billing_phone;
// Order Tax Cost
$order_tax = $order->order_tax;
// Order Shipping Cost
$order_shippingcost = $order->order_shipping;
// Order Currency
$order_currency = $order->order_currency;
// Product Category
$order_category = $order->term_id;
// Product Name
$order_product = $order->item_id;
// Product Quantity
$order_quantity = $order->quantity;
// Product SKU
$order_sku = $order->sku;
// Product Price
$order_price = $order->price;
?>
<!-- Start Tracking code -->
<script type="text/javascript">
var _ss = _ss || [];
_ss.push(['_setDomain', 'xxxxxxxx']);
_ss.push(['_setAccount', 'xxxxxxx']);
_ss.push(['_trackPageView']);
(function() {
var ss = document.createElement('script');
ss.type = 'text/javascript'; ss.async = true;
ss.src = ('https:' == document.location.protocol ? 'https://' :
'http://') + 'koi-3Q40EJNC5K.marketingautomation.services/client/ss.js?
ver=1.1.1';
var scr = document.getElementsByTagName('script')[0];
scr.parentNode.insertBefore(ss, scr);
})();
</script>
<script type='text/javascript'>
_ss.push(['_setTransaction', {
'transactionID': '<?php echo $order_id; ?>',
'storeName': 'Reco Surfaces',
'total': '<?php echo $order_total; ?>',
'tax': '<?php echo $order_tax; ?>',
'shipping': '<?php echo $order_shippingcost; ?>',
'city': '<?php echo $order_billcity; ?>',
'state': '<?php echo $order_billstate; ?>',
'zipcode': '<?php echo $order_billpostcode; ?>',
'country': 'UK',
'firstName' : '<?php echo $order_fname; ?>',
'lastName' : '<?php echo $order_lname; ?>',
'emailAddress' : '<?php echo $order_email ?>'
}, function() {
_ss.push(['_addTransactionItem', {
'transactionID': '<?php echo $order_id; ?>',
'itemCode': '<?php echo $order_sku; ?>',
'productName': '<?php echo $order_product; ?>',
'category': '<?php echo $order_category; ?>',
'price': '<?php echo $order_price; ?>',
'quantity': '<?php echo $order_quantity; ?>'
}]);
_ss.push(['_completeTransaction', {
'transactionID': '<?php echo $order_id; ?>'
}]);
}]);
</script>
<!-- End Tracking code -->
<?php
}