编辑 woocommerce 结帐页面 "order notes"
Editing the woocommerce checkout page "order notes"
我想将 woocommerce 结帐页面的 'order notes' 文本字段更改为 'special notes'。但是我找不到这个文件的确切位置。在我的本地主机文件夹中的什么地方可以找到这个文件?
页面截图如下:
要实现这一点,您需要使用 woocommerce_checkout_fields 过滤器并设置 $fields['order']['order_comments']['label']到你想要的文字。
这是它的代码。您应该将其添加到主题的 function.php 文件或插件中。
add_filter( 'woocommerce_checkout_fields', 'change_order_note_label' );
/**
* Change Order Notes Label - WooCommerce
*
*/
function change_order_note_label( $fields ) {
$fields['order']['order_comments']['label'] = 'Special notes';
return $fields;
}
这种情况直接不要尝试在插件文件中编辑。而不是尝试搜索钩子。
这是您可以在函数文件中添加的代码。它也会更改文本和占位符
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' );
对我有用
add_filter('woocommerce_checkout_fields','theme_override_checkout_notes_fields');
// 我们的钩子函数 - $fields 通过过滤器传递!
函数 theme_override_checkout_notes_fields( $字段 ) {
$fields['order']['order_comments']['placeholder'] = 'Add some order notes or a gift message here.';
$fields['order']['order_comments']['label'] = 'Order notes or gift message';
return $字段;
}
我想将 woocommerce 结帐页面的 'order notes' 文本字段更改为 'special notes'。但是我找不到这个文件的确切位置。在我的本地主机文件夹中的什么地方可以找到这个文件?
页面截图如下:
要实现这一点,您需要使用 woocommerce_checkout_fields 过滤器并设置 $fields['order']['order_comments']['label']到你想要的文字。
这是它的代码。您应该将其添加到主题的 function.php 文件或插件中。
add_filter( 'woocommerce_checkout_fields', 'change_order_note_label' );
/**
* Change Order Notes Label - WooCommerce
*
*/
function change_order_note_label( $fields ) {
$fields['order']['order_comments']['label'] = 'Special notes';
return $fields;
}
这种情况直接不要尝试在插件文件中编辑。而不是尝试搜索钩子。
这是您可以在函数文件中添加的代码。它也会更改文本和占位符
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' );
对我有用
add_filter('woocommerce_checkout_fields','theme_override_checkout_notes_fields');
// 我们的钩子函数 - $fields 通过过滤器传递! 函数 theme_override_checkout_notes_fields( $字段 ) { $fields['order']['order_comments']['placeholder'] = 'Add some order notes or a gift message here.'; $fields['order']['order_comments']['label'] = 'Order notes or gift message'; return $字段; }