Change title “Additional Information” in woocommerce

≯℡__Kan透↙ 提交于 2019-12-23 02:21:13

问题


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

回答1:


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>



回答2:


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



回答3:


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;

}


来源:https://stackoverflow.com/questions/33394078/change-title-additional-information-in-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!