Search code examples
phpwoocommercecartcheckoutgettext

Change "Total" text in WooCommerce cart and checkout pages


WooCommerce uses wc_cart_totals_order_total_html() function to display the "formatted order total amount (including tax if needed)" in cart page (and checkout too).

In the cart page (and checkout), I would like to be able to add the text "Amount to be paid:" next to the displayed total amount.

Any help is appreciated.


Solution

  • To alter, the text "Total" displayed next to the formatted displayed total amount (in cart and checkout pages), you can use a custom function hooked in WordPress gettext hook as follows:

    add_filter( 'gettext', 'change_some_woocommerce_strings', 10, 3 );
    function change_some_woocommerce_strings( $translate_text, $original_text, $domain ) {
        if ( $original_text === 'Total' && $domain === 'woocommerce' && ( is_cart() || is_checkout() ) ) {
            $translate_text = __('Amount to be paid', $domain);
        }
    
        return $translate_text;
    }
    

    Code goes in functions.php file of the active child theme (or active theme). Tested and works.