Hello everyone,
I’m working on a multi-vendor plugin (Dokan Pro).
I have Main Categories for Women, Men and Kids. Below them are the clothing categories. There are T-shirt under clothing.
So,
Women> Clothing> T-shirt
Men’s> Clothing> T-shirt
Kids> Clothing> T-shirt.
Vendor searches in the -Select Category- section while adding products. For example, T-shirt.
Three different trousers appear and the main categories do not appear (For example, Women, Men and Children).
In such a case, of course the vendor cannot make the right choice. What would you suggest for this ?
The corresponding code is below:
“`
<?php if ( dokan_get_option( ‘product_category_style’, ‘dokan_selling’, ‘single’ ) == ‘single’ ): ?>
<div class=”dokan-form-group”>
<label for=”product_cat” class=”form-label”><?php esc_html_e( ‘Category’, ‘dokan-lite’ ); ?></label>
<?php
$product_cat = -1;
$term = array();
$term = wp_get_post_terms( $post_id, ‘product_cat’, array( ‘fields’ => ‘ids’) );
if ( $term ) {
$product_cat = reset( $term );
}
include_once DOKAN_LIB_DIR.’/class.category-walker.php’;
$category_args = array(
‘show_option_none’ => __( ‘- Select a category -‘, ‘dokan-lite’ ),
‘hierarchical’ => 1,
‘hide_empty’ => 0,
‘name’ => ‘product_cat’,
‘id’ => ‘product_cat’,
‘taxonomy’ => ‘product_cat’,
‘title_li’ => ”,
‘class’ => ‘product_cat dokan-form-control dokan-select2’,
‘exclude’ => ”,
‘selected’ => $product_cat,
‘walker’ => new CategoryDropdownSingle( $post_id )
);
wp_dropdown_categories( apply_filters( ‘dokan_product_cat_dropdown_args’, $category_args ) );
?>
Update,
This came to my mind. ([Image
Is it possible to rewrite the code this way?
Or any other idea?