3

On my Woocommerce website, I need to display Total Order Amount in words, which will be shown on Checkout Page, Cheque Payment & on Invoice.

Example: 1590.00 (One thousand five hundred & ninety only)

How can we achieve this? TIA

tushonline
  • 270
  • 3
  • 16

1 Answers1

2

You can try number formatter class as mentioned in these threads a and b

Use the filter "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' );

You can also try the other hooks like woocommerce_get_formatted_order_total

Community
  • 1
  • 1
Lax Mariappan
  • 146
  • 1
  • 7
  • 1
    Perfect. This worked. Thank you Here is the final code I used for Invoice & cheque payments. `$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;` – tushonline Oct 14 '16 at 14:54
  • Thanks for revert back with working code. I will use this snippet too. – Lax Mariappan Oct 14 '16 at 16:38