所以我在实施,为了拉动信息自定义跟踪代码的问题。自定义跟踪代码谢谢
下面是我在functions.php文件已经走到这一步,它实际上没有显示任何信息,不过,当我进行购买。
add_action('woocommerce_thankyou', 'conversion_tracking');
function conversion_tracking() {
$order = wc_get_order($order_id);
$order_id = $order->get_id;
$order_parent_id = $order->get_parent_id;
$order_status = $order->get_status;
$order_currency = $order->get_currency;
$order_version = $order->get_version;
$order_payment_method = $order->get_payment_method;
$order_payment_method_title = $order->get_payment_method_title;
$order_payment_method = $order->get_payment_method;
$order_payment_method = $order->get_payment_method;
?>
<script type = 'text/javascript'>
window.sovIframes = window.sovIframes || [];
window.sovIframes.push({
trafficSourceNumber : '',
trafficMediumNumber : '',
timestamp : '<?php echo $order_timestamp_created ?>',
orderId : '<?php echo $order_id ?>',
orderValue : '<?php echo $order_total ?>',
orderCurrency : '<?php echo $order_currency ?>',
});
<?php
}
当我尝试使用此代码拉订单数据:
$order = wc_get_order($order_id);
$order_data = $order->get_data();
$order_id = $order_data['id'];
$order_parent_id = $order_data['parent_id'];
$order_status = $order_data['status'];
$order_currency = $order_data['currency'];
$order_version = $order_data['version'];
$order_payment_method = $order_data['payment_method'];
$order_payment_method_title = $order_data['payment_method_title'];
$order_payment_method = $order_data['payment_method'];
$order_payment_method = $order_data['payment_method'];
我得到以下错误:
在我的functions.phpFatal error: Uncaught Error: Call to a member function get_data() on boolean in /home/feratino/www/REMOVED/wp-content/themes/REMOVED/functions.php:28 Stack trace: 0 /home/feratino/www/REMOVED/wp-includes/class-wp-hook.php(298): sovendus_conversion_tracking(109947)
1 /home/REMOVED/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array)
2 /home/feratino/www/REMOVED/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
3 /home/feratino/www/REMOVED/wp-content/plugins/woocommerce/templates/checkout/thankyou.php(74): do_action('woocommerce_tha...', 109947)
4 /home/feratino/www/REMOVED/wp-content/plugins/woocommerce/includes/wc-core-functions.php(204): include('/home/feratino/...')
5 /home/feratino/www/REMOVED/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php(205): wc_get_template('checkout/thanky...', Array)
6 /home/feratino/www/REMOVED/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-s in /home/feratino/www/REMOVED/wp-content/themes/REMOVED/functions.php on line 28
第28行:
$order_data = $order->get_data();
它的工作原理!谢谢。 –