Only certain attributes mandatory. Please help.
-
Hello WCFM admins @wclovers and people on the internet!
The last reply on this topic https://ww.wp.xz.cn/support/topic/important-shipping-cost-calculation/ by @wclovers was
“– DO you want to apply this on any particular attribute? If so, then know me “slug” for that attribute.”I need exactly that. Please.
The code to make all attributes mandatory is:
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);I just need to make Color (slug: color), Size (slug: size) and Product weight (slug: product-weight) mandatory while keeping all the others optional.
Please @wclovers
The page I need help with: [log in to see the link]
The topic ‘Only certain attributes mandatory. Please help.’ is closed to new replies.