WCFM attributes filed required is not working
-
I have used WCFM plugin. I want my all attributes make required in product form as a vendor. I have used some function in functions.php in child theme but after validation is not working.
add_filter( 'wcfm_product_custom_attributes', function( $taxonomy_fields, $att_taxonomy ) { if( isset( $taxonomy_fields[$att_taxonomy] ) && isset( $taxonomy_fields[$att_taxonomy]['value'] ) ) { $attributes = $taxonomy_fields[$att_taxonomy]['value']; $wcfm_attributes = array(); if( !empty( $attributes ) ) { foreach( $attributes as $acnt => $wcfm_attribute ) { $wcfm_attributes[$acnt] = $wcfm_attribute; $wcfm_attributes[$acnt]['is_active'] = 'enable'; $wcfm_attributes[$acnt]['is_visible'] = 'enable'; } } $taxonomy_fields[$att_taxonomy]['value'] = $wcfm_attributes; } return $taxonomy_fields; }, 50, 2); add_filter( 'wcfm_product_custom_attributes', function( $taxonomy_fields, $att_taxonomy ) { if( isset( $taxonomy_fields[$att_taxonomy] ) && isset( $taxonomy_fields[$att_taxonomy]['options'] ) ) { if( isset( $taxonomy_fields[$att_taxonomy]['options']['is_active'] ) ) { $taxonomy_fields[$att_taxonomy]['options']['is_active']['custom_attributes'] = array( 'required' => 1, 'required_message' => 'Attributes are required' ); } if( isset( $taxonomy_fields[$att_taxonomy]['options']['value'] ) ) { $taxonomy_fields[$att_taxonomy]['options']['value']['custom_attributes'] = array( 'required' => 1, 'required_message' => 'Attributes are required' ); } } return $taxonomy_fields; }, 50, 2);
- The topic ‘WCFM attributes filed required is not working’ is closed to new replies.