【问题标题】:Adding the order currency to the order note woocommerce将订单货币添加到订单备注 woocommerce
【发布时间】:2021-07-19 19:47:06
【问题描述】:

我正在尝试编写一个函数,将客户为在线订单支付的货币添加到 woocommerce 中客户的订单备注中。我写的函数是这样的:

add_action( 'woocommerce_new_order', 'add_currency',  1, 1  );
    function add_currency( $order_id ) {
    $order = new WC_Order( $order_id ); 
    $note = $order_currency;
    $order->add_order_note( $note );
}

任何帮助将不胜感激

【问题讨论】:

  • 您好,您能澄清一下您所说的客户订单备注是什么意思吗?哪个位置?因为它们出现在 WooCommerce 中的多个位置。也许有截图?
  • @7uc1f3r 我已附上截图,感谢您的建议

标签: php wordpress woocommerce currency


【解决方案1】:

我看到你还没有声明 $order_currency

您可以通过以下方式获取货币相关的字符串:

$order = wc_get_order( $order_id );
$currency_code = $order->get_currency();
$currency_symbol = get_woocommerce_currency_symbol( $currency_code );

【讨论】:

    猜你喜欢
    • 2022-01-20
    • 2016-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-12
    • 2013-04-20
    • 2021-04-08
    相关资源
    最近更新 更多