PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 All 91 releases
← All changes | src/Addons/GlobalTieredPricing/LookupService.php +79 -1 6.1.0 → 8.0.2 View file →
@@ -10,12 +10,16 @@
10 10
11 11 use ServiceContainerTrait;
12 12
13 13 const CATEGORIES_SEARCH_ACTION = 'woocommerce_json_search_tpt_categories';
14 - const CUSTOMERS_SEARCH_ACTION = 'woocommerce_json_search_tpt_customers';
14 + const TAGS_SEARCH_ACTION = 'woocommerce_json_search_tpt_tags';
15 + const BRANDS_SEARCH_ACTION = 'woocommerce_json_search_tpt_brands';
16 + const CUSTOMERS_SEARCH_ACTION = 'woocommerce_json_search_tpt_customers';
15 17
16 18 public function __construct() {
17 19 add_action( 'wp_ajax_' . self::CATEGORIES_SEARCH_ACTION, array( $this, 'categoriesSearchHandler' ) );
20 + add_action( 'wp_ajax_' . self::TAGS_SEARCH_ACTION, array( $this, 'tagsSearchHandler' ) );
21 + add_action( 'wp_ajax_' . self::BRANDS_SEARCH_ACTION, array( $this, 'brandsSearchHandler' ) );
18 22 add_action( 'wp_ajax_' . self::CUSTOMERS_SEARCH_ACTION, array( $this, 'customersSearchHandler' ) );
19 23 }
20 24
21 25 public function customersSearchHandler() {
@@ -93,8 +97,82 @@
93 97 }
94 98 }
95 99
96 100 wp_send_json( $_terms );
101 + }
102 + }
103 +
104 + wp_send_json( array() );
105 + }
106 +
107 + public function tagsSearchHandler() {
108 + if ( ! current_user_can( 'manage_options' ) ) {
109 + wp_send_json( array() );
110 + }
111 +
112 + $term = isset( $_GET['term'] ) ? sanitize_text_field( $_GET['term'] ) : false;
113 +
114 + if ( $term ) {
115 + $args = array(
116 + 'taxonomy' => array( 'product_tag' ),
117 + 'orderby' => 'id',
118 + 'order' => 'ASC',
119 + 'limit' => 5,
120 + 'hide_empty' => false,
121 + 'fields' => 'all',
122 + 'name__like' => $term
123 + );
124 +
125 + $terms = get_terms( $args );
126 +
127 + if ( $terms && ! is_wp_error( $terms ) ) {
128 + $_terms = array();
129 +
130 + foreach ( $terms as $term ) {
131 + if ( $term instanceof WP_Term ) {
132 + $_terms[ $term->term_id ] = $term->name;
133 + }
134 + }
135 +
136 + wp_send_json( $_terms );
137 + }
138 + }
139 +
140 + wp_send_json( array() );
141 + }
142 +
143 + public function brandsSearchHandler() {
144 + if ( ! current_user_can( 'manage_options' ) ) {
145 + wp_send_json( array() );
146 + }
147 +
148 + $term = isset( $_GET['term'] ) ? sanitize_text_field( $_GET['term'] ) : false;
149 +
150 + if ( $term ) {
151 + if ( taxonomy_exists( 'product_brand' ) ) {
152 + $args = array(
153 + 'taxonomy' => array( 'product_brand' ),
154 + 'orderby' => 'id',
155 + 'order' => 'ASC',
156 + 'limit' => 5,
157 + 'hide_empty' => false,
158 + 'fields' => 'all',
159 + 'name__like' => $term
160 + );
161 +
162 + $terms = get_terms( $args );
163 +
164 + if ( $terms && ! is_wp_error( $terms ) ) {
165 + $_terms = array();
166 +
167 + foreach ( $terms as $term ) {
168 + if ( $term instanceof WP_Term ) {
169 + $_terms[ $term->term_id ] = $term->name;
170 + }
171 + }
172 +
173 + wp_send_json( $_terms );
174 + }
97 175 }
98 176 }
99 177
100 178 wp_send_json( array() );