【问题标题】:WooCommerce: How To Get Order ID & TotalWooCommerce:如何获取订单 ID 和总计
【发布时间】:2017-08-07 03:15:10
【问题描述】:

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

像素是这样的格式:

<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 之前,它可以正常使用这个 sn-p:

Snippet

现在它不工作了。 如果有任何帮助,我将不胜感激。谢谢! ????

【问题讨论】:

  • 网址看起来很奇怪.../slug=1234&amp;slug=125.00。这不应该是?order=1234&amp;total=125.00吗?

标签: php wordpress woocommerce


【解决方案1】:
$order->get_formatted_order_total()

用货币符号给出总数。

$order->get_total()

给出不带货币符号的总数。

【讨论】:

    【解决方案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()
    ); 
    ?>
    

    【讨论】:

    • 嘿,网址只是示例 :) 非常感谢,它成功了!
    猜你喜欢
    • 2014-03-05
    • 2020-05-08
    • 2017-07-08
    • 1970-01-01
    • 2019-09-08
    • 2021-07-14
    • 2021-11-23
    • 2020-07-20
    • 2018-03-23
    相关资源
    最近更新 更多