Woocommerce:如何用单词显示'订单总额'

时间:2016-10-13 19:33:22

标签: wordpress woocommerce

在我的Woocommerce网站上,我需要显示 Total Order Amount字样,这将显示在Checkout页面,Check Payment&在发票上。

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

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

1 个答案:

答案 0 :(得分:2)

您可以尝试使用这些主题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

相关问题