• Resolved shemakeswebsites

    (@shemakeswebsites)


    How do we limit the product tags per item? Without a limit, vendors can easily abuse tags and destroy load speeds with excessive taxonomies. Please advise, thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @shemakeswebsites ,

    Thanks for reaching out.

    We use the Select2 to load those tags and categories. You can use the “data-maximum-selection-length” attribute to limit the number of tags you want to allow.

    For example, to limit the number of tags on the add product page you need to open the file – dokan-lite/template/products/new-product.php and navigate to line #270 and add the mentioned attribute like this –

    echo str_replace( '<select', '<select data-placeholder="'.esc_attr__( 'Select product tags', 'dokan-lite' ).'" multiple="multiple" data-maximum-selection-length="3"' , $drop_down_tags );

    This will stop the user from selecting more than 3 items in the tags field – https://prnt.sc/t9k36o

    You need to repeat the procedure for dokan-lite/template/products/new-product-single.php file as well.

    Thank you.

    Thread Starter shemakeswebsites

    (@shemakeswebsites)

    Thank you so much!

    Thread Starter shemakeswebsites

    (@shemakeswebsites)

    Hello, it looks like code was changed in the latest update and the suggestion provided earlier no longer works. Can you please help?

    <div class="dokan-form-group">
                                            <label for="product_tag" class="form-label"><?php esc_html_e( 'Tags', 'dokan-lite' ); ?></label>
                                            <?php
                                            require_once DOKAN_LIB_DIR.'/class.taxonomy-walker.php';
                                            
                                            $drop_down_tags = array(
                                                'hide_empty' => 0,
                                            );
    
                                            $my_tax_terms = get_terms( 'product_tag', $drop_down_tags );
                                            ?>
                                            <select multiple="multiple" placeholder="<?php esc_attr_e( 'Select product tags', 'dokan-lite' ); ?>" name="product_tag[]" id="product_tag_search" class="product_tags dokan-form-control dokan-select2">
                                            </select>
                                        </div>

    What do I edit to limit the amount of tags per product please?

    Hello @shemakeswebsites ,

    Oh! no problem we can still use a similar solution.

    Replace the line #259 with this –

    <select multiple="multiple" data-maximum-selection-length="3" placeholder="<?php esc_attr_e( 'Select product tags', 'dokan-lite' ); ?>" name="product_tag[]" id="product_tag_search" class="product_tags dokan-form-control dokan-select2"></select>

    This should like before.

    Thank you.

    Thread Starter shemakeswebsites

    (@shemakeswebsites)

    Thank you. ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Limit product tag’ is closed to new replies.