Clawdius
Clawdius

Reputation: 27

Change wording on Woocommerce Checkout page

Thanks to help here: Change Billing details text to Shipping details I could change Billing details text on Woocommerce Checkout page by adding this to functions.php in Child theme:

function wc_billing_field_strings( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Billing details' :
            $translated_text = __( 'Billing Info', 'woocommerce' );
            break;
    }
    return $translated_text;
}
add_filter( 'gettext', 'wc_billing_field_strings', 20, 3 );

What are the codes to change these 3 additional texts with different wording: Additional information, PRODUCT & QUANTITY (see screenshot): Woocommerce Checkout Page

Upvotes: 1

Views: 7075

Answers (1)

melvin
melvin

Reputation: 2621

It would be better to override the checkout/form-checkout.php and checkout/review-order.php

Or You can use gettext filter .

This filter hook is applied to the translated text by the internationalization functions (__(), _e(), etc.)

function th_wc_order_review_strings( $translated_text, $text, $domain ) {

  if(is_checkout()){
    switch ($translated_text) {
      case 'Billing details' :
        $translated_text = __( 'Billing Info', 'woocommerce' );
        break;
      case 'Additional information':
        $translated_text = __('New Field Name', 'woocommerce');
        break;
     case 'Your order':
        $translated_text = __('My Order', 'woocommerce');
        break;
     case 'Product':
        $translated_text = __('Your Product', 'woocommerce');
        break;
    }
  }
  return $translated_text;
}
add_filter( 'gettext', 'th_wc_order_review_strings', 20, 3 );

Try changing the above code to your requirements.

Upvotes: 3

Related Questions