Adrian Vazquez
Adrian Vazquez

Reputation: 347

Change title "Additional Information" in woocommerce

I want to change the title from the checkout page. But I just can change the label and the placeholder.

// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
     $fields['order']['order_comments']['placeholder'] = 'Please type your PO number here and we will add it to the invoice.';
     $fields['order']['order_comments']['label'] = '';
     return $fields;
}

Upvotes: 1

Views: 25337

Answers (6)

WebMat
WebMat

Reputation: 135

The documentation of Woocommerce is not complety...

https://docs.woocommerce.com/document/editing-product-data-tabs/

You would check condition about the callback before add or replace some value in array, otherwise the tab will display with nothing inside.

/**
 * Filter product data tabs
 */
function filter_product_tabs( $tabs ) {

    global $product;

    if ( isset($tabs['description']['callback']) ) {
        $tabs['description']['title'] = __( 'More Information' );            // Rename the description tab
        $tabs['description']['priority'] = 5;           // Description
    }

    if ( isset($tabs['additional_information']['callback']) ) {
        $tabs['additional_information']['title'] = __( 'Product Data' );     // Rename the additional information tab
        $tabs['additional_information']['priority'] = 10;   // Additional information
    }

    if ( isset($tabs['reviews']['callback']) ) {
        $tabs['reviews']['title'] = __( 'Review' ) . ' (' . $product->get_review_count() . ') ';  // Rename the reviews tab
        $tabs['reviews']['priority'] = 15;          // Reviews
    }

    return $tabs;
}
add_filter( 'woocommerce_product_tabs', 'filter_product_tabs', 98 );

Why ? because the developper Woocommerce will check the content of array in the tab template (version 3.8.0) (WC

/**
 * Filter tabs and allow third parties to add their own.
 *
 * Each tab is an array containing title, callback and priority.
 *
 * @see woocommerce_default_product_tabs()
 */

$product_tabs = apply_filters( 'woocommerce_product_tabs', array() );
    
    if ( ! empty( $product_tabs ) ) : 

....

Upvotes: 0

Cyberdome
Cyberdome

Reputation: 41

https://docs.woocommerce.com/document/editing-product-data-tabs/#

/**
 * Rename product data tabs
 */
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );

function woo_rename_tabs( $tabs ) {
    $tabs['description']['title'] = __( 'More Information' );            // Rename the description tab
    $tabs['reviews']['title'] = __( 'Ratings' );                         // Rename the reviews tab
    $tabs['additional_information']['title'] = __( 'Product Data' );     // Rename the additional information tab

    return $tabs;
}

Upvotes: 4

Gantsta
Gantsta

Reputation: 31

This solution worked for me:

function ajg_relabel_additional_information_tab(){
    return __( 'Specification', 'text-domain' );
}
add_filter('woocommerce_product_additional_information_heading', 'ajg_relabel_additional_information_tab');

Upvotes: 2

Amit Garg
Amit Garg

Reputation: 570

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 );

Upvotes: 1

Anna Wellington
Anna Wellington

Reputation: 323

This worked for me if anyone is still after this change

//Shipping Weight custom tab name

add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {

    $tabs['additional_information']['title'] = __( 'Additional Information' );  // Rename the Additional Information text
    return $tabs;

}

Upvotes: -1

Scriptonomy
Scriptonomy

Reputation: 4055

As it stands there is not hook to change the section title. But here's the hack if you are desperate enough to make the modification.

  1. Locate your template folder
  2. Create a folder named 'checkout'
  3. Locate the file form-shipping.php in the Woocommerce plugin foler under templates/checkout/
  4. Copy file in step 3 to the folder created in step 2
  5. Now you have superpowers over the checkout form

Edit this line:

<h3><?php _e( 'Additional Information', 'woocommerce' ); ?></h3>

Upvotes: 2

Related Questions