1

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

melvin
  • 2,571
  • 1
  • 14
  • 37
Clawdius
  • 27
  • 1
  • 6

1 Answers1

3

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.

melvin
  • 2,571
  • 1
  • 14
  • 37
  • Thanks melvin, That worked but only for "Billing details". How to change Additional information, PRODUCT & QUANTITY. I'm adding the code to functions.php in Child theme. The page is here: (https://tokyopicnics.com/checkout/) Thanks! – Clawdius Oct 08 '18 at 07:00
  • @Clawdius Check my answer. I have updated. Also you can override template file to change the label if there are no other issues – melvin Oct 08 '18 at 07:07
  • @Clawdius There was case sensitive issues in my answer that i have updated. Check now. Hope everything works fine – melvin Oct 08 '18 at 07:16
  • That's great! 3 done! but "Additional information" still won't change. Don't think there is a template file. Can't find it so using functions.php on Child. Thanks! – Clawdius Oct 08 '18 at 07:22
  • Can you find the template file in which the `Additional information` is written using a text editor ? Also have you checked there is no case sensitive issues ? @Clawdius – melvin Oct 08 '18 at 07:24
  • You could see something like this `__( 'Additional information', 'woocommerce' ) ` in your template. You have to type the same to change the text – melvin Oct 08 '18 at 07:30
  • It was a case sensitive issue: case 'Additional information': had a capital i. All fine now. Thanks a lot!! – Clawdius Oct 08 '18 at 07:30
  • @Clawdius Happy i could help. Please upvote the answer by clicking on the up arrow icon on the left side of answer once you have sufficient reputation so that someone will find the answer helpful – melvin Oct 08 '18 at 07:35
  • @Clawdius Happy i could help. Please upvote the answer by clicking on the up arrow icon on the left side of answer once you have sufficient reputation so that someone will find the answer helpful – melvin Oct 08 '18 at 07:36
  • Sorry again, one more issue after this fix: The site is bilingual English/Japanese. On Japanese site on the homepage there are 4 Picnic products. When I click "Reserve" then "Add to Cart" next to it, it goes to English Checkout page not Japanese. It was ok before. Can you help? Thanks! – Clawdius Oct 09 '18 at 10:54
  • @Clawdius i don't know much about that. It can be any wpml issues – melvin Oct 09 '18 at 11:12
  • @Clawdius is that issue still there when you remove the above answer ? – melvin Oct 09 '18 at 11:19
  • yes, I activated the main theme and the issue was still there – Clawdius Oct 09 '18 at 11:33
  • @Clawdius try removing the code i give you and if still issue persists, then that's something else – melvin Oct 09 '18 at 11:39
  • I also tried removing code from child and issue still there – Clawdius Oct 09 '18 at 11:40
  • @Clawdius So this issue is something else. Find your recent changes you made to any of the pages and change it back – melvin Oct 09 '18 at 12:13
  • Ok Thanks for your help – Clawdius Oct 09 '18 at 12:19
  • @Clawdius sorry for i couldn't help – melvin Oct 09 '18 at 12:35
  • Hi again. That issue is fixed now but now the homepage is loading very slowly (10 seconds). I found it's because of the code you gave for functions.php. When I use Child-theme with code - very slow. When I change to main theme with no code - normal. When I add the code to main theme in editor - back to very slow. Do you know how I can keep the code and normal homepage loading speed? Thanks! – Clawdius Oct 12 '18 at 15:00
  • @Clawdius the filter i gave you check each translation on every page for matching text. I have given an `is_checkout` function to ensure that the switch is executed only in checkout page. When the match is found the replace is applied. . This is the maximum i can optimize. So if the delay is due to code, then it is better to override the template file. – melvin Oct 16 '18 at 04:31
  • Thanks again! Will try – Clawdius Oct 18 '18 at 10:34
  • I'm getting a 502 error when adding a new code snippet with this code – JulienVan Oct 15 '20 at 10:16
  • @JulienVan Where did you add this code? Just checked now and it works – melvin Oct 15 '20 at 10:40
  • @melvin in the Code Snippet plugin – JulienVan Nov 26 '20 at 04:54