Title: Make attribute requied
Last modified: December 11, 2020

---

# Make attribute requied

 *  Resolved [sujeet036](https://wordpress.org/support/users/sujeet036/)
 * (@sujeet036)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/make-attribute-requied/)
 * I want some attribute to required. The vendor has to fill an attribute. Without
   attribute, the vendor should not able to add products.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Rashed Ripon (a11n)](https://wordpress.org/support/users/rur165/)
 * (@rur165)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/make-attribute-requied/#post-13781398)
 * Hello [@sujeet036](https://wordpress.org/support/users/sujeet036/) ,
 * Attributes in the product edit field is only available in Dokan Pro. If you have
   any queries regarding a feature available in the Pro version please contact our
   support from your weDevs account.
 * Thank you 🙂
 *  Thread Starter [sujeet036](https://wordpress.org/support/users/sujeet036/)
 * (@sujeet036)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/make-attribute-requied/#post-13794907)
 * Ok
 *  [niikk](https://wordpress.org/support/users/niikk/)
 * (@niikk)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/make-attribute-requied/#post-13837204)
 * [@sujeet036](https://wordpress.org/support/users/sujeet036/)
 * Did you solve this? We have the same requirement. 🙂
 *  Thread Starter [sujeet036](https://wordpress.org/support/users/sujeet036/)
 * (@sujeet036)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/make-attribute-requied/#post-13837267)
 * Yes, I will update you tomorrow. You have to edit dokan files.
 *  [niikk](https://wordpress.org/support/users/niikk/)
 * (@niikk)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/make-attribute-requied/#post-13837325)
 * [@sujeet036](https://wordpress.org/support/users/sujeet036/)
 * Cool! Looking forward for your feedback 🙂
 * Cheers! 🙂
 *  Thread Starter [sujeet036](https://wordpress.org/support/users/sujeet036/)
 * (@sujeet036)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/make-attribute-requied/#post-13838394)
 * Please check the below code. I make the Brand attribute required.
 * File – wp-content/plugins/dokan-pro/templates/products/product-variation.php
 *     ```
       <?php
       /**
        * Dokan Dashboard Product Variation Template
        *
        * @since 2.4
        *
        * @package dokan
        */
       ?>
       <script>
           jQuery(document).ready(function(){
   
               $(':input[type="submit"]').prop('disabled', true);
               jQuery("[name='predefined_attribute']").change(function(){
                   if(jQuery(this).val()=='pa_brand'){
                       jQuery('.add_new_attribute').click();
                       $(':input[type="submit"]').prop('disabled', false);
                   }
               });
           });
       </script>
       <div >
           <div class="dokan-section-heading" data-togglehandler="dokan_attribute_variation_options">
               <h2><i class="fa fa-list-alt" aria-hidden="true"></i> <?php _e( 'Attribute', 'dokan' ); ?><span class="show_if_variable show_if_variable-subscription"><?php _e( ' and Variation', 'dokan' ) ?></span></h2>
               <p class="show_if_variable show_if_variable-subscription"><?php _e( 'Manage attributes and variations for this variable product.', 'dokan' ); ?></p>
               <p class="show_if_simple show_if_subscription show_if_grouped"><?php _e( 'Manage attributes for this simple product.', 'dokan' ); ?></p>
   
               <a href="#" class="dokan-section-toggle">
                   <i class="fa fa-sort-desc fa-flip-vertical" aria-hidden="true"></i>
               </a>
   
               <div class="dokan-clearfix"></div>
           </div>
           <div class="dokan-section-content">
               <div class="dokan-product-attribute-wrapper show_if_simple show_if_subscription show_if_variable show_if_subscription show_if_variable-subscription show_if_grouped">
   
                   <ul class="dokan-attribute-option-list">
                       <?php
                       global $wc_product_attributes;
   
                       // Product attributes - taxonomies and custom, ordered, with visibility and variation attributes set
                       $attributes           = maybe_unserialize( get_post_meta( $post_id, '_product_attributes', true ) );
   
                       // Output All Set Attributes
                       if ( ! empty( $attributes ) ) {
                           $attribute_keys  = array_keys( $attributes );
                           $attribute_total = sizeof( $attribute_keys );
   
                           for ( $i = 0; $i < $attribute_total; $i ++ ) {
                               $attribute     = $attributes[ $attribute_keys[ $i ] ];
                               $position      = empty( $attribute['position'] ) ? 0 : absint( $attribute['position'] );
                               $taxonomy      = '';
                               $metabox_class = array();
   
                               if ( $attribute['is_taxonomy'] ) {
                                   $taxonomy = $attribute['name'];
   
                                   if ( ! taxonomy_exists( $taxonomy ) ) {
                                       continue;
                                   }
   
                                   $attribute_taxonomy = $wc_product_attributes[ $taxonomy ];
                                   $metabox_class[]    = 'taxonomy';
                                   $metabox_class[]    = $taxonomy;
                                   $attribute_label    = wc_attribute_label( $taxonomy );
                               } else {
                                   $attribute_label    = apply_filters( 'woocommerce_attribute_label', $attribute['name'], $attribute['name'], false );
                               }
   
                               dokan_get_template_part( 'products/edit/html-product-attribute', '', array(
                                   'pro'                => true,
                                   'thepostid'          => $post_id,
                                   'taxonomy'           => $taxonomy,
                                   'attribute_taxonomy' => isset( $attribute_taxonomy ) ? $attribute_taxonomy : null,
                                   'attribute_label'    => $attribute_label,
                                   'attribute'          => $attribute,
                                   'metabox_class'      => $metabox_class,
                                   'position'           => $position,
                                   'i'                  => $i
                               ) );
   
                           }
                       }
                       ?>
                   </ul>
                   <span style="font-weight:600;">Note: Choosing a brand is mandatory</span>
                   <div class="dokan-attribute-type">
   
                       <select name="predefined_attribute" required id="predefined_attribute" class="dokan-w5 dokan-form-control dokan_attribute_taxonomy" data-predefined_attr='<?php echo json_encode( $attribute_taxonomies ); ?>' >
                           <option value=""><?php _e( 'Custom Attribute', 'dokan' ); ?></option>
                           <?php
                           if ( ! empty( $attribute_taxonomies ) ) {
                               foreach ( $attribute_taxonomies as $tax ) {
                                   $attribute_taxonomy_name = wc_attribute_taxonomy_name( $tax->attribute_name );
                                   $label = $tax->attribute_label ? $tax->attribute_label : $tax->attribute_name;
                                   echo '<option value="' . esc_attr( $attribute_taxonomy_name ) . '">' . esc_html( $label ) . '</option>';
                               }
                           }
                           ?>
                       </select>
                       <a href="#" class="dokan-btn dokan-btn-default add_new_attribute"><?php _e( 'Add attribute', 'dokan' ) ?></a>
                       <a href="#" class="dokan-btn dokan-btn-default dokan-btn-theme dokan-save-attribute"><?php _e( 'Save attribute', 'dokan' ) ?></a>
                       <span class="dokan-spinner dokan-attribute-spinner dokan-hide"></span>
                   </div>
               </div>
   
               <div class="dokan-product-variation-wrapper show_if_variable show_if_variable-subscription">
                   <?php dokan_product_output_variations(); ?>
               </div>
           </div>
       </div>
       ```
   
    -  This reply was modified 5 years, 5 months ago by [sujeet036](https://wordpress.org/support/users/sujeet036/).
 *  [niikk](https://wordpress.org/support/users/niikk/)
 * (@niikk)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/make-attribute-requied/#post-13838498)
 * [@sujeet036](https://wordpress.org/support/users/sujeet036/)
 * Thanks. Is this also working for simple products?

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Make attribute requied’ is closed to new replies.

 * ![](https://ps.w.org/dokan-lite/assets/icon-256x256.gif?rev=3239229)
 * [Dokan: AI Powered WooCommerce Multivendor Marketplace Solution – Build Your Own Amazon, eBay, Etsy](https://wordpress.org/plugins/dokan-lite/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/dokan-lite/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/dokan-lite/)
 * [Active Topics](https://wordpress.org/support/plugin/dokan-lite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/dokan-lite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/dokan-lite/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [niikk](https://wordpress.org/support/users/niikk/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/make-attribute-requied/#post-13838498)
 * Status: resolved