Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devendrabisht/9b86b8be6af8fc61f2e541e3140876ee to your computer and use it in GitHub Desktop.
Save devendrabisht/9b86b8be6af8fc61f2e541e3140876ee to your computer and use it in GitHub Desktop.
WooCommerce make order notes required in checkout
/**
* Make order notes required
*/
add_filter( 'woocommerce_checkout_fields' , 'dev_woocommerce_make_order_comments_required' );
function dev_woocommerce_make_order_comments_required( $fields ) {
$fields['order']['order_comments']['required'] = true;
return $fields;
}
// add_action( 'woocommerce_after_checkout_validation', 'dev_woocommerce_add_notice_for_empty_order_comments' );
// function dev_woocommerce_add_notice_for_empty_order_comments() {
// // Check if set, if its not set add an error.
// if ( ! $_POST['order_comments'] ) {
// wc_add_notice( __( 'Please enter order notes.' ), 'error' );
// }
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment