Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Njengah/de98ef7bf514c3e4e4efa06d8f863532 to your computer and use it in GitHub Desktop.
Save Njengah/de98ef7bf514c3e4e4efa06d8f863532 to your computer and use it in GitHub Desktop.
WooCommerce make order notes or order comments required https://njengah.com/make-woocommerce-order-comments-required/
<?php
/**
* Code Snippet should be added to the functions.php to make WooCommerce order comments required
*/
add_action('woocommerce_after_checkout_validation', 'njengah_make_woocommerce_order_comments_required');
function njengah_make_woocommerce_order_comments_required() {
// Check if order comments are set, if its not set add an error.
if ( ! $_POST['order_comments'] )
wc_add_notice( __( 'Please add delivery instructions' ), 'error' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment