【问题标题】:Woocommerce: How-to show ‘Order Total’ amount in WordsWoocommerce:如何用文字显示“订单总额”金额
【发布时间】:2016-10-13 19:33:22
【问题描述】:

在我的 Woocommerce 网站上,我需要用文字显示 Total Order Amount,它将显示在结帐页面、支票付款和发票上。

示例:1590.00 (One thousand five hundred & ninety only)

我们怎样才能做到这一点? TIA

【问题讨论】:

标签: wordpress woocommerce


【解决方案1】:

您可以尝试这些线程ab 中提到的数字格式化程序类

使用过滤器“woocommerce_cart_totals_order_total_html”。

function custom_woocommerce_order_amount_total( $order_total ) { 
$number_total = WC()->cart->get_total();
// number formatting goes here;
// using number formatter class 
$f = new NumberFormatter("en", NumberFormatter::SPELLOUT);
$total_in_words = $f->format($number_total); // Total in words
$order_total =   $total_in_words;      
return $order_total; 
    }; 
    add_filter( 'woocommerce_cart_totals_order_total_html', 'custom_woocommerce_order_amount_total' );

你也可以试试其他的钩子,比如 woocommerce_get_formatted_order_total

【讨论】:

  • 完美。这行得通。谢谢 这是我用于发票和支票付款的最终代码。 $number_total = $this->order->get_total(); // number formatting goes here; // using number formatter class $f = new NumberFormatter("en", NumberFormatter::SPELLOUT); $total_in_words = $f->format($number_total); // Total in words $order_total = $total_in_words; echo $order_total;
  • 感谢您恢复工作代码。我也会用这个sn-p。
猜你喜欢
  • 2019-09-13
  • 1970-01-01
  • 2021-11-23
  • 2017-07-11
  • 2016-02-18
  • 1970-01-01
  • 1970-01-01
  • 2010-11-08
  • 2014-07-29
相关资源
最近更新 更多