【发布时间】:2016-10-13 19:33:22
【问题描述】:
在我的 Woocommerce 网站上,我需要用文字显示 Total Order Amount,它将显示在结帐页面、支票付款和发票上。
示例:1590.00 (One thousand five hundred & ninety only)
我们怎样才能做到这一点? TIA
【问题讨论】:
标签: wordpress woocommerce
在我的 Woocommerce 网站上,我需要用文字显示 Total Order Amount,它将显示在结帐页面、支票付款和发票上。
示例:1590.00 (One thousand five hundred & ninety only)
我们怎样才能做到这一点? TIA
【问题讨论】:
标签: wordpress woocommerce
使用过滤器“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;