WooCommerce:如何获得订单ID&总

时间:2017-08-06 10:11:37

标签: php wordpress woocommerce

也许有人可以在这个论坛帮助我?因此,我必须使用thank-you.php页面像素来跟踪潜在客户。

Pixel就像这种格式:

<img src="https://example.com/path/slug=*ORDERID*&slug=*TOTAL*" alt="" width="1" height="1" border="0" />

ORDERID 中我需要获取没有“#”的订单ID,而在 TOTAL 中我必须获得没有货币符号的订单总数。

所以它必须看起来像:

<img src="https://example.com/path/slug=123456&slug=125.00" alt="" width="1" height="1" border="0" />

订单ID#123456,订单总金额125.00€。

在将WooCommerce更新为3.0之前,这个代码段正常运行:

Snippet

现在它不起作用了。 我会非常感谢任何帮助。谢谢!

2 个答案:

答案 0 :(得分:2)

这适用于WooCommerce 3.0及更高版本:

<?php 
printf(
    '<img src="https://example.com/path/order=%s&total=%s" width="1" height="1" border="0" />',
    $order->get_id(),
    $order->get_total()
); 
?>

答案 1 :(得分:2)

$order->get_formatted_order_total()

给出货币符号总数。

$order->get_total()

给出没有货币符号的总数。