Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save plugin-republic/46d9247ce6371b644916eb985f202036 to your computer and use it in GitHub Desktop.
Save plugin-republic/46d9247ce6371b644916eb985f202036 to your computer and use it in GitHub Desktop.
<?php
/**
* Validate our custom text input field value
*/
function plugin_republic_add_to_cart_validation( $passed, $product_id, $quantity, $variation_id=null ) {
if( empty( $_POST['pr-field'] ) ) {
$passed = false;
wc_add_notice( __( 'Your name is a required field.', 'plugin-republic' ), 'error' );
}
return $passed;
}
add_filter( 'woocommerce_add_to_cart_validation', 'plugin_republic_add_to_cart_validation', 10, 4 );
@plugin-republic
Copy link
Author

Hi - the full article is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment