• Resolved raghadmadwar

    (@raghadmadwar)


    Hi,
    i;ve made this menu to make some changes i want
    but it’s not working can you tell me what i’ve missed??
    i want to make the parent category disabled and not available to choose

    $taxonomy     = 'product_cat';
                                            $orderby      = 'id';
                                            $show_count   = 0;      // 1 for yes, 0 for no
                                            $pad_counts   = 0;      // 1 for yes, 0 for no
                                            $hierarchical = 1;      // 1 for yes, 0 for no  
                                            $title        = '';
                                            $empty        = 0;
    
                                            $args = array(
    
                                                'id'               => 'product_cat',
                                                'taxonomy'     => $taxonomy,
                                                'orderby'      => $orderby,
                                                'show_count'   => $show_count,
                                                'pad_counts'   => $pad_counts,
                                                'hierarchical' => $hierarchical,
                                                'title_li'     => $title,
                                                'hide_empty'   => $empty,
                                                'exclude'          => '',
                                                'hide_empty'       => 0,
    
                                            );
                                            $all_categories = get_categories($args);
                                            echo '<select name="cat" method="post">';
                                            foreach ($all_categories as $cat) {
                                                if ($cat->category_parent == 0) {
                                                    $category_id = $cat->term_id;
                                                    echo '<option disabled>' . $cat->name . '</option>';
    
                                                    $args2 = array(
    
                                                        'id'               => 'product_cat',
                                                        'taxonomy'     => $taxonomy,
                                                        'child_of'     => 0,
                                                        'hide_empty'       => 0,
                                                        'parent'       => $category_id,
                                                        'orderby'      => $orderby,
                                                        'show_count'   => $show_count,
                                                        'pad_counts'   => $pad_counts,
                                                        'hierarchical' => $hierarchical,
                                                        'title_li'     => $title,
                                                        'hide_empty'   => $empty,
                                                        'exclude'          => '',
    
                                                    );
                                                    $sub_cats = get_categories($args2);
                                                    if ($sub_cats) {
                                                        foreach ($sub_cats as $sub_category) {
                                                            echo  '<option value="'. $sub_category->term_id.'">' . $sub_category->name .'</option>';
                                                        }
                                                    }
                                                }
                                            }
                                            echo '</select>';
    
                                        update_post_meta($product_id, 'category', $get_data['cat']);
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @raghadmadwar ,

    I appreciate your effort to customize Dokan to meet your need.

    However, we are unable to debug a custom code according to our support policy. We share the codes if we already have an example code available. Unfortunately, I do not have an example to share in this case. I am keeping this thread open for others to join in.

    Thank you 🙂

    Hi @rur165,

    Since we haven’t got any response for long, so I mark this ticket as resolved. If you’ve any further queries, feel free to create a new thread.

    Thank you,

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

The topic ‘dokan category drop_down’ is closed to new replies.