是否有结帐错误消息过滤器
Is there a filter for Checkout Error Message
我想编辑结帐页面上的文字。 There are some issues with the items in your cart. Please go back to the cart page and resolve these issues before checking out.
我一直在寻找无需编辑源文件即可对其进行编辑的方法。是否有过滤器可以编辑结帐页面上的文本?
试过这个
add_action( 'woocommerce_after_checkout_validation', 'quadlayers', 9999, 2);
function quadlayers( $fields, $errors ){
// in case any validation errors
if( !empty( $errors->get_error_codes() ) ) {
// omit all existing error messages
foreach( $errors->get_error_codes() as $code ) {
$errors->remove( $code );
}
// display custom single error message
$errors->add( 'validation', 'Your Custom Message Goes Here!!!' );
}
}
add_filter('gettext_woocommerce', 'modify_cart_error_message', 10, 3);
function modify_cart_error_message($translation, $text, $domain) {
if ('There are some issues with the items in your cart. Please go back to the cart page and resolve these issues before checking out.' === $translation) {
$translation = 'Your Custom Message Goes Here!!!';
}
return $translation;
}
提到的购物车错误消息来自 /woocommerce/templates/checkout/cart-errors.php
文件。您可以覆盖主题中的模板或在活动主题functions.php
文件
中使用以上代码片段
我想编辑结帐页面上的文字。 There are some issues with the items in your cart. Please go back to the cart page and resolve these issues before checking out.
我一直在寻找无需编辑源文件即可对其进行编辑的方法。是否有过滤器可以编辑结帐页面上的文本?
试过这个
add_action( 'woocommerce_after_checkout_validation', 'quadlayers', 9999, 2);
function quadlayers( $fields, $errors ){
// in case any validation errors
if( !empty( $errors->get_error_codes() ) ) {
// omit all existing error messages
foreach( $errors->get_error_codes() as $code ) {
$errors->remove( $code );
}
// display custom single error message
$errors->add( 'validation', 'Your Custom Message Goes Here!!!' );
}
}
add_filter('gettext_woocommerce', 'modify_cart_error_message', 10, 3);
function modify_cart_error_message($translation, $text, $domain) {
if ('There are some issues with the items in your cart. Please go back to the cart page and resolve these issues before checking out.' === $translation) {
$translation = 'Your Custom Message Goes Here!!!';
}
return $translation;
}
提到的购物车错误消息来自 /woocommerce/templates/checkout/cart-errors.php
文件。您可以覆盖主题中的模板或在活动主题functions.php
文件