Skip to content

Commit

Permalink
fix: Product tags search more optimized (#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
alamgircsebd authored Sep 8, 2020
1 parent b13a8d6 commit e1d9ab5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion assets/src/js/product-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@

$(document).ready(function () {
// Ajax search products tags
$("#product_tag_search").select2({
$(".product_tag_search").select2({
allowClear: false,
tags: true,
ajax: {
Expand Down
14 changes: 6 additions & 8 deletions templates/products/new-product-single.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,20 +313,18 @@ class="vendor-earning simple-product"
<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';
$term = wp_get_post_terms( $post_id, 'product_tag', array( 'fields' => 'ids') );
$terms = wp_get_post_terms( $post_id, 'product_tag', array( 'fields' => 'all' ) );

$drop_down_tags = array(
'hide_empty' => 0,
);

$my_tax_terms = get_terms( 'product_tag', $drop_down_tags );
?>
<select multiple="multiple" name="product_tag[]" id="product_tag_search" class="product_tags dokan-form-control dokan-select2">
<?php foreach ( $my_tax_terms as $tax_term ) : ?>
<?php if ( ! empty( $term ) && in_array( $tax_term->term_id, $term ) ) : ?>
<select multiple="multiple" name="product_tag[]" id="product_tag_search" class="product_tag_search product_tags dokan-form-control dokan-select2">
<?php if ( ! empty( $terms ) ) : ?>
<?php foreach ( $terms as $tax_term ) : ?>
<option value="<?php echo esc_attr( $tax_term->term_id ); ?>" selected="selected" ><?php echo esc_html( $tax_term->name ); ?></option>
<?php endif ?>
<?php endforeach ?>
<?php endforeach ?>
<?php endif ?>
</select>
</div>

Expand Down

0 comments on commit e1d9ab5

Please sign in to comment.