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 plugin-republic/c5c47053031635927e6435c0b4525ca9 to your computer and use it in GitHub Desktop.
Save plugin-republic/c5c47053031635927e6435c0b4525ca9 to your computer and use it in GitHub Desktop.
<?php
/**
* Custom validation for add-on fields
*/
function prefix_filter_validate_cart_item_status( $passed, $post, $item ) {
// pewc_group_3990_4033 is the ID of the field
if( isset( $post['pewc_group_3990_4033'] ) && floatval( $post['pewc_group_3990_4033'] ) < 10 ) {
wc_add_notice( 'My validation message', 'error' );
$passed = false;
}
return $passed;
}
add_filter( 'pewc_filter_validate_cart_item_status', 'prefix_filter_validate_cart_item_status', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment