Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'wcfm_form_custom_validation', function( $form_data, $screen ) {
- if( 'product_manage' == $screen ) {
- if(isset($_POST['status']) && ($_POST['status'] == 'draft')) {
- $product_status = 'draft';
- } else {
- if( apply_filters( 'wcfm_is_allow_publish_products', true ) ) {
- $product_status = 'publish';
- } else {
- $product_status = 'pending';
- }
- }
- if( 'publish' == $product_status ) {
- if( isset( $form_data['manage_stock'] ) && 'enable' == $form_data['manage_stock'] ) {
- if( isset( $form_data['stock_qty'] ) && $form_data['stock_qty'] <= 0 ) {
- $form_data = [
- 'has_error' => true,
- 'message' => __( 'Stock quantity can not be 0 or less', 'wc-frontend-manager' )
- ];
- }
- }
- }
- }
- return $form_data;
- }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement