简体   繁体   中英

Change order notes checkout field placeholder in Woocommerce

In woocommerce, I am wondering how to remove from the "Order notes" checkout field placeholder this text "eg special notes for delivery", as my store does not ship products and it just sounds out of context.

So I am trying to edit the template checkout/form-shipping.php without success.

How to change order notes checkout field placeholder?

Any help is appreciated.

You don't need to edit any template file, jsut use the following code snippet:

add_filter( 'woocommerce_checkout_fields' , 'change_order_notes_placeholder' );
function change_order_notes_placeholder( $fields ) {
     $fields['order']['order_comments']['placeholder'] = _x('Notes about your order...', 'placeholder', 'woocommerce');

     return $fields;
}

Code goes in function.php file of your active child theme (or active theme). Tested and work.

在此处输入图片说明

Add the below coding inside function.php file in your child theme.

function md_custom_woocommerce_checkout_fields( $fields ) 
    {
        $fields['order']['order_comments']['placeholder'] = 'Special notes';
        $fields['order']['order_comments']['label'] = 'Add your special note';
    
        return $fields;
    }
    add_filter( 'woocommerce_checkout_fields', 'md_custom_woocommerce_checkout_fields' );

There's also translation possibility. Goes inside functions.php of your child or main theme or any code snippet plugin. Tested and works.

Will do the trick if earlier solutions won't work.

add_filter('gettext', 'translate_text',999);

function translate_text($translated) {
    $translated = str_ireplace('Your old placeholder text', 'New placeholder text', $translated);
    return $translated;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM