Skip to content

Instantly share code, notes, and snippets.

@WebEndevSnippets
Created November 13, 2012 16:30
Show Gist options
  • Save WebEndevSnippets/4066777 to your computer and use it in GitHub Desktop.
Save WebEndevSnippets/4066777 to your computer and use it in GitHub Desktop.
WooCommerce: Change Order Notes Placeholder Text
add_filter( 'woocommerce_checkout_fields', 'webendev_woocommerce_checkout_fields' );
/**
* Change Order Notes Placeholder Text - WooCommerce
*
*/
function webendev_woocommerce_checkout_fields( $fields ) {
$fields['order']['order_comments']['placeholder'] = 'Your custom placeholder';
return $fields;
}
@Jeremwp
Copy link

Jeremwp commented Aug 22, 2016

Hello,

Can we use this code for child theme ?

I'm using wpml , will i be able to translate it the order notes later ?

Thanks you so much

@monecchi
Copy link

@Jeremwp - You should be able to translate it with WPML or with your theme's .po translation file by replacing
'Your custom placeholder'; with __('Your custom placeholder', 'text-domain');, where "text-domain" is the name defined by your theme for all its translation strings, so please replace it accordingly.

@AarthnaMaheshwari
Copy link

Is it required to return $fields from this function? I just want to set a value in order notes

@iabidali
Copy link

iabidali commented Dec 1, 2017

In order emails, its name remains the same. Can you change that too? Specifically for the Note:

@Lubosza85
Copy link

Hi guys please help me , so much i need this.

I use WooCommerce and I would need to change the text behind the order note. I have a ORDER NOTE (OPTIONAL) - and I need a change this (OPTIONAL) to other text.

thanks so much i send print scree - i look to google but i find only funcion to change text - ORDER NOTE not change (OPTIONAL).
13

Thank so so much to answer

@nottiesweather
Copy link

Simple & useful. Appreciate the upload.

@lacasitadelosanimales
Copy link

lacasitadelosanimales commented Aug 1, 2018

I have personalized the Custom Order Notes Text and made it required and works ok but the placeholder text when you type in gets out of the text field. any solution? This is the code i´ve used in the theme child functions.php

<?php
// Add custom Theme Functions here
// WC order notes field
add_filter('woocommerce_checkout_fields', 'custom_woocommerce_checkout_fields');

function custom_woocommerce_checkout_fields( $fields ) {

     $fields['order']['order_comments']['placeholder'] = 'Horario de Entrega y Notas Pedido | Península: Indique una franja de 3h entre las 9h y las 19h | Alcorcón: Elija horario Mañanas de 12h a 14h y/o Tardes de 17h a 19h';

     return $fields;
}
/*-----------------------------------------------------------------------------------*/
/*	WooCommerce - Change Checkout Notes Label and Place Holder Text
/*-----------------------------------------------------------------------------------*/

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

// Our hooked in function - $fields is passed via the filter!
function theme_override_checkout_notes_fields( $fields ) {
     $fields['order']['order_comments']['placeholder'] = 'Horario de Entrega y Notas del Pedido | Península: Indique una franja de 3h entre las 9h y las 19h | Alcorcón: Elija horario Mañanas de 12h a 14h y/o Tardes de 17h a 19h*';
     $fields['order']['order_comments']['label'] = 'Horario de Entraga y Notas del Pedido';
     return $fields;
}
// Hacer campo notas pedido obligatorio. Place this code in your theme's functions.php file

// 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']['required'] = true;
     return $fields;
}

Screesnhot
link

Link to Web

@aronmoshe-m
Copy link

Woohoo! Thanks. Saved me time here.

@ikazi1
Copy link

ikazi1 commented Feb 11, 2019

Great. Thanks.

@palilaStudio
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment