PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.87
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.87
51.1.87 51.1.86 51.1.84 51.1.85 51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 All 41 releases
← All changes | includes/widgets/Facet_Price/Facet_Price.php +54 -12 51.1.44 → 51.1.87 View file →
@@ -35,12 +35,22 @@
35 35 * @return string
36 36 */
37 37 public function get_title(): string
38 38 {
39 - return esc_html__('Facet Price', 'king-addons');
39 + return esc_html__('Price Filter', 'king-addons');
40 40 }
41 41
42 42 /**
43 + * Keywords.
44 + *
45 + * @return array<int, string>
46 + */
47 + public function get_keywords(): array
48 + {
49 + return ['shop', 'product', 'filter', 'filters', 'ajax', 'woocommerce', 'price', 'range', 'faceted', 'smart filters'];
50 + }
51 +
52 + /**
43 53 * Widget icon.
44 54 *
45 55 * @return string
46 56 */
@@ -45,9 +55,9 @@
45 55 * @return string
46 56 */
47 57 public function get_icon(): string
48 58 {
49 - return 'eicon-range-slider';
59 + return 'king-addons-icon king-addons-facet-price';
50 60 }
51 61
52 62 /**
53 63 * Categories.
@@ -82,9 +92,14 @@
82 92 KING_ADDONS_ASSETS_UNIQUE_KEY . '-facet-price-script',
83 93 ];
84 94 }
85 95
86 - /**
96 + public function get_custom_help_url()
97 + {
98 + return 'mailto:[email protected]?subject=Bug Report - King Addons&body=Please describe the issue';
99 + }
100 +
101 + /**
87 102 * Register controls.
88 103 *
89 104 * @return void
90 105 */
@@ -92,9 +107,9 @@
92 107 {
93 108 $this->start_controls_section(
94 109 'kng_facet_price_section',
95 110 [
96 - 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Facet Price', 'king-addons'),
111 + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Price Filter', 'king-addons'),
97 112 'tab' => Controls_Manager::TAB_CONTENT,
98 113 ]
99 114 );
100 115
@@ -100,11 +115,12 @@
100 115
101 116 $this->add_control(
102 117 'kng_filters_query_id',
103 118 [
104 - 'label' => esc_html__('Filter Query ID', 'king-addons'),
119 + 'label' => esc_html__('Shop Filters ID', 'king-addons'),
105 120 'type' => Controls_Manager::TEXT,
106 121 'placeholder' => esc_html__('shop_grid_1', 'king-addons'),
122 + 'description' => esc_html__('Must match the Shop Filters ID on the product grid.', 'king-addons'),
107 123 ]
108 124 );
109 125
110 126 $this->add_control(
@@ -134,9 +150,27 @@
134 150 'min' => 0.1,
135 151 ]
136 152 );
137 153
154 + $this->add_control(
155 + 'kng_variable_price',
156 + [
157 + 'label' => esc_html__('Variable products', 'king-addons'),
158 + 'type' => Controls_Manager::SELECT,
159 + 'default' => 'any',
160 + 'options' => [
161 + 'any' => esc_html__('Match if any variation is in range', 'king-addons'),
162 + 'displayed' => esc_html__('Match by the price shown on the card', 'king-addons'),
163 + ],
164 + 'description' => esc_html__('A variable product may show “from €150” while other variations cost more. “Any variation” keeps it in the results when a shopper filters from €250 and a €260 option exists. “Card price” uses only the number on the card, usually the minimum.', 'king-addons'),
165 + ]
166 + );
167 +
138 168 $this->end_controls_section();
169 +
170 + require_once KING_ADDONS_PATH . 'includes/helpers/Faceted/Style_Controls.php';
171 + Facet_Style_Controls::fields($this, '{{WRAPPER}} .king-addons-facet--price .king-addons-facet__input');
172 + Facet_Style_Controls::buckets($this);
139 173 }
140 174
141 175 /**
142 176 * Render widget output.
@@ -154,12 +188,13 @@
154 188
155 189 $min = isset($settings['kng_min_value']) ? (float) $settings['kng_min_value'] : 0;
156 190 $max = isset($settings['kng_max_value']) ? (float) $settings['kng_max_value'] : 0;
157 191 $step = isset($settings['kng_step']) ? (float) $settings['kng_step'] : 1;
192 + $variable_price = (($settings['kng_variable_price'] ?? 'any') === 'displayed') ? 'displayed' : 'any';
158 193 $show_buckets = true;
159 194
160 195 ?>
161 - <div class="king-addons-facet king-addons-facet--price" data-ka-filters-query-id="<?php echo esc_attr($query_id); ?>">
196 + <div class="king-addons-facet king-addons-facet--price" data-ka-filters-query-id="<?php echo esc_attr($query_id); ?>" data-ka-variable-price="<?php echo esc_attr($variable_price); ?>">
162 197 <div class="king-addons-facet__row">
163 198 <label class="king-addons-facet__label">
164 199 <?php echo esc_html__('Min', 'king-addons'); ?>
165 200 <input
@@ -198,10 +233,17 @@
198 233 ['min' => 250, 'max' => 999999],
199 234 ],
200 235 'woo_products_grid'
201 236 );
202 - foreach ($buckets as $idx => $bucket) :
203 - $label = sprintf('%s - %s', wc_price($bucket['min']), wc_price($bucket['max']));
237 + foreach ($buckets as $bucket) :
238 + $bucket_min = isset($bucket['min']) ? (float) $bucket['min'] : 0;
239 + $bucket_max = isset($bucket['max']) ? (float) $bucket['max'] : 999999;
240 + $bucket_key = $bucket_min . '-' . $bucket_max;
241 + if ($bucket_max >= 999999) {
242 + $label = sprintf('%s+', wc_price($bucket_min));
243 + } else {
244 + $label = sprintf('%s - %s', wc_price($bucket_min), wc_price($bucket_max));
245 + }
204 246 ?>
205 247 <li class="king-addons-facet__bucket">
206 248 <button
207 249 type="button"
@@ -207,15 +249,15 @@
207 249 type="button"
208 250 class="king-addons-facet__bucket-btn"
209 251 data-ka-filter-type="price-bucket"
210 252 data-ka-filters-query-id="<?php echo esc_attr($query_id); ?>"
211 - data-ka-price-bucket="<?php echo esc_attr((string) $idx); ?>"
212 - data-ka-price-min="<?php echo esc_attr($bucket['min']); ?>"
213 - data-ka-price-max="<?php echo esc_attr($bucket['max']); ?>"
253 + data-ka-price-bucket="<?php echo esc_attr($bucket_key); ?>"
254 + data-ka-price-min="<?php echo esc_attr((string) $bucket_min); ?>"
255 + data-ka-price-max="<?php echo esc_attr((string) $bucket_max); ?>"
214 256 data-ka-price-label="<?php echo esc_attr(wp_strip_all_tags($label)); ?>"
215 257 >
216 258 <span class="king-addons-facet__bucket-label"><?php echo wp_kses_post($label); ?></span>
217 - <span class="king-addons-facet__bucket-count" data-ka-price-bucket="<?php echo esc_attr((string) $idx); ?>"></span>
259 + <span class="king-addons-facet__bucket-count" data-ka-price-bucket="<?php echo esc_attr($bucket_key); ?>"></span>
218 260 </button>
219 261 </li>
220 262 <?php endforeach; ?>
221 263 </ul>