简体   繁体   中英

Woocommerce Checkout Errors Edit

I want to change the error messages coming from the checkout page.

Can anyone help me?

在此处输入图片说明

I can see that the strings are in the woocommerce.pot file.

Sure you can, just add a filter to the hook woocommerce_checkout_required_field_notice .

function filter_woocommerce_checkout_required_field_notice( $sprintf, $field_label ) {
    $my_custom_notice = '' . $field_label . ' and my custom notice!';
    return sprintf( __( '%s is a required field.', 'woocommerce' ), $my_custom_notice ); 
}

add_filter( 'woocommerce_checkout_required_field_notice', 'filter_woocommerce_checkout_required_field_notice', 10, 2 );

Try changing the content of error box to something like "Field with * are required".

<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#Id_of_Error_Container").html('<p class="red">Fields with * are required</p>');
});
</script>

Add this to footer.php and change #Id_of_Error_Container with div id of error box.

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