From 641358ab8d16b434efcb6e69d7a1ec26ff1b4f49 Mon Sep 17 00:00:00 2001 From: Aftabul Islam Date: Thu, 11 May 2023 15:51:56 +0600 Subject: [PATCH 1/6] feat: New Walker added for category dropdown multiselect --- assets/src/js/script.js | 5 ++ .../Walkers/CategoryDropdownMultiSelect.php | 52 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 includes/Walkers/CategoryDropdownMultiSelect.php diff --git a/assets/src/js/script.js b/assets/src/js/script.js index b9e8e2eccd..e39a3f8ff9 100755 --- a/assets/src/js/script.js +++ b/assets/src/js/script.js @@ -867,6 +867,11 @@ jQuery(function($) { } }); + /** + * Coupon category search + */ + $('.dokan-category-search').select2({}); + /** * Trigger bulk item checkbox selections */ diff --git a/includes/Walkers/CategoryDropdownMultiSelect.php b/includes/Walkers/CategoryDropdownMultiSelect.php new file mode 100644 index 0000000000..495e319051 --- /dev/null +++ b/includes/Walkers/CategoryDropdownMultiSelect.php @@ -0,0 +1,52 @@ +name, $category ); + + if ( isset( $args['value_field'] ) && isset( $category->{$args['value_field']} ) ) { + $value_field = $args['value_field']; + } else { + $value_field = 'term_id'; + } + + $output .= "\t\n"; + + } + +} From 64f181f536a2b393c5541dfe1c387b4c2be3f1a9 Mon Sep 17 00:00:00 2001 From: Aftabul Islam Date: Thu, 11 May 2023 16:08:15 +0600 Subject: [PATCH 2/6] fix: PHPCS issue fix --- includes/Walkers/CategoryDropdownMultiSelect.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/includes/Walkers/CategoryDropdownMultiSelect.php b/includes/Walkers/CategoryDropdownMultiSelect.php index 495e319051..166c5b8994 100644 --- a/includes/Walkers/CategoryDropdownMultiSelect.php +++ b/includes/Walkers/CategoryDropdownMultiSelect.php @@ -9,7 +9,7 @@ */ class CategoryDropdownMultiSelect extends \Walker_CategoryDropdown { - public function start_el( &$output, $data_object, $depth = 0, $args = [], $current_object_id = 0 ): void { + public function start_el( &$output, $data_object, $depth = 0, $args = [], $current_object_id = 0 ) { // Restores the more descriptive, specific name for use within this method. $category = $data_object; @@ -46,7 +46,5 @@ function( $item ) { $output .= '  (' . number_format_i18n( $category->count ) . ')'; } $output .= "\n"; - } - } From eae8ba23ba6035bf238dbf12efed51c2629d7801 Mon Sep 17 00:00:00 2001 From: Aftabul Islam Date: Thu, 11 May 2023 16:20:42 +0600 Subject: [PATCH 3/6] fix: PHPCS issue fix --- includes/Walkers/CategoryDropdownMultiSelect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Walkers/CategoryDropdownMultiSelect.php b/includes/Walkers/CategoryDropdownMultiSelect.php index 166c5b8994..68f48e54d8 100644 --- a/includes/Walkers/CategoryDropdownMultiSelect.php +++ b/includes/Walkers/CategoryDropdownMultiSelect.php @@ -37,7 +37,7 @@ function( $item ) { if ( in_array( (string) $category->{$value_field}, $args['multiselect'], true ) ) { $output .= ' selected="selected"'; } - } else if ( (string) $category->{$value_field} === (string) $args['selected'] ) { + } elseif ( (string) $category->{$value_field} === (string) $args['selected'] ) { $output .= ' selected="selected"'; } $output .= '>'; From 66a53d43c3cac0bf453e568664c7654e0ad01aef Mon Sep 17 00:00:00 2001 From: Aftabul Islam Date: Thu, 25 May 2023 14:31:20 +0600 Subject: [PATCH 4/6] refactor: Removed unnecessary walker. --- .../Walkers/CategoryDropdownMultiSelect.php | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 includes/Walkers/CategoryDropdownMultiSelect.php diff --git a/includes/Walkers/CategoryDropdownMultiSelect.php b/includes/Walkers/CategoryDropdownMultiSelect.php deleted file mode 100644 index 68f48e54d8..0000000000 --- a/includes/Walkers/CategoryDropdownMultiSelect.php +++ /dev/null @@ -1,50 +0,0 @@ -name, $category ); - - if ( isset( $args['value_field'] ) && isset( $category->{$args['value_field']} ) ) { - $value_field = $args['value_field']; - } else { - $value_field = 'term_id'; - } - - $output .= "\t\n"; - } -} From a1d0f083249b55620b342e2cfee779366f85a157 Mon Sep 17 00:00:00 2001 From: Aftabul Islam Date: Wed, 14 Jun 2023 15:20:57 +0600 Subject: [PATCH 5/6] fix: Product coupon association removed is dokan pro exists --- includes/Order/Hooks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Order/Hooks.php b/includes/Order/Hooks.php index 2760da2b27..80d46f28b5 100644 --- a/includes/Order/Hooks.php +++ b/includes/Order/Hooks.php @@ -373,8 +373,8 @@ public function ensure_vendor_coupon( $valid, $coupon, $discount ) { return $valid; } - // A coupon must be bound with a product - if ( count( $coupon->get_product_ids() ) === 0 ) { + // A coupon must be bound with a product if pro is deactivated + if ( ! dokan()->is_pro_exists() && count( $coupon->get_product_ids() ) === 0 ) { throw new Exception( __( 'A coupon must be restricted with a vendor product.', 'dokan-lite' ) ); } From 94f020080d668c35e21ba79bb0b06fac104d4d73 Mon Sep 17 00:00:00 2001 From: Aftabul Islam Date: Wed, 14 Jun 2023 15:28:54 +0600 Subject: [PATCH 6/6] fix: Unnecessary code removed --- assets/src/js/script.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/assets/src/js/script.js b/assets/src/js/script.js index e39a3f8ff9..b9e8e2eccd 100755 --- a/assets/src/js/script.js +++ b/assets/src/js/script.js @@ -867,11 +867,6 @@ jQuery(function($) { } }); - /** - * Coupon category search - */ - $('.dokan-category-search').select2({}); - /** * Trigger bulk item checkbox selections */