PluginProbe
Datafeedr API / 1.4.3
Datafeedr API v1.4.3
1.4.3 1.4.2 1.0.125 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.3 1.0.30 1.0.31 1.0.32 All 182 releases
← All changes | classes/class-dfrapi-searchform.php +707 -246 1.0.2 → 1.4.3 View file →
@@ -1,208 +1,366 @@
1 1 <?php
2 2
3 +defined( 'ABSPATH' ) || exit;
3 4
4 5
5 6 class Dfrapi_SearchForm
6 7 {
7 8 function fields() {
8 - $opFulltext = array(
9 - 'contain' => __( 'contains', DFRAPI_DOMAIN ),
10 - 'not_contain' => __( 'doesn\'t contain', DFRAPI_DOMAIN ),
11 - 'start' => __( 'starts with', DFRAPI_DOMAIN ),
12 - 'end' => __( 'ends with', DFRAPI_DOMAIN ),
13 - 'match' => __( 'matches', DFRAPI_DOMAIN )
14 - );
15 - $opFulltextExact = array_merge($opFulltext, array(
16 - 'is' => __( 'is', DFRAPI_DOMAIN )
17 - ));
18 - $opRange = array(
19 - 'lt' => __( 'less than', DFRAPI_DOMAIN ),
20 - 'gt' => __( 'greater than', DFRAPI_DOMAIN ),
21 - 'between' => __( 'between', DFRAPI_DOMAIN )
22 - );
23 - $opIs = array(
24 - 'is' => __( 'is', DFRAPI_DOMAIN )
25 - );
26 - $opIsIsnt = array(
27 - 'is' => __( 'is', DFRAPI_DOMAIN ),
28 - 'is_not' => __( 'isn\'t', DFRAPI_DOMAIN )
29 - );
30 - $opYesNo = array(
31 - 'yes' => __( 'yes', DFRAPI_DOMAIN ),
32 - 'no' => __( 'no', DFRAPI_DOMAIN )
33 - );
34 9
35 - $sortOpts = array(
36 - '' => __( 'Relevance', DFRAPI_DOMAIN ),
37 - '+price' => __( 'Price Ascending', DFRAPI_DOMAIN ),
38 - '-price' => __( 'Price Decending', DFRAPI_DOMAIN ),
39 - '+saleprice' => __( 'Sale Price Ascending', DFRAPI_DOMAIN ),
40 - '-saleprice' => __( 'Sale Price Decending', DFRAPI_DOMAIN ),
41 - '+salediscount' => __( 'Discount Ascending', DFRAPI_DOMAIN ),
42 - '-salediscount' => __( 'Discount Decending', DFRAPI_DOMAIN ),
43 - '+merchant' => __( 'Merchant', DFRAPI_DOMAIN ),
44 - '+time_updated' => __( 'Last updated Ascending', DFRAPI_DOMAIN ),
45 - '-time_updated' => __( 'Last updated Decending', DFRAPI_DOMAIN )
46 - );
10 + $opFulltext = array(
11 + 'match' => __( 'matches', 'datafeedr-api' ),
12 + 'contain' => __( 'contains', 'datafeedr-api' ),
13 + 'not_contain' => __( 'doesn\'t contain', 'datafeedr-api' ),
14 + 'start' => __( 'starts with', 'datafeedr-api' ),
15 + 'end' => __( 'ends with', 'datafeedr-api' ),
16 + );
47 17
48 - return array(
49 - array(
50 - 'title' => __( 'Any field', DFRAPI_DOMAIN ),
51 - 'name' => 'any',
52 - 'input' => 'text',
53 - 'operator' => $opFulltext
54 - ),
55 - array(
56 - 'title' => __( 'Product name', DFRAPI_DOMAIN ),
57 - 'name' => 'name',
58 - 'input' => 'text',
59 - 'operator' => $opFulltextExact,
60 - ),
61 - array(
62 - 'title' => __( 'Brand', DFRAPI_DOMAIN ),
63 - 'name' => 'brand',
64 - 'input' => 'text',
65 - 'operator' => $opFulltextExact,
66 - ),
67 - array(
68 - 'title' => __( 'Description', DFRAPI_DOMAIN ),
69 - 'name' => 'description',
70 - 'input' => 'text',
71 - 'operator' => $opFulltext,
72 - ),
73 - array(
74 - 'title' => __( 'Tags', DFRAPI_DOMAIN ),
75 - 'name' => 'tags',
76 - 'input' => 'text',
77 - 'operator' => array(
78 - 'in' => __( 'contain', DFRAPI_DOMAIN ),
79 - 'not_in' => __( 'don\'t contain', DFRAPI_DOMAIN )
80 - )
81 - ),
82 - array(
83 - 'title' => __( 'Category', DFRAPI_DOMAIN ),
84 - 'name' => 'category',
85 - 'input' => 'text',
86 - 'operator' => $opFulltext
87 - ),
88 - array(
89 - 'title' => __( 'Product type', DFRAPI_DOMAIN ),
90 - 'name' => 'type',
91 - 'input' => 'select',
92 - 'options' => array(
93 - 'products' => __( 'Product', DFRAPI_DOMAIN ),
94 - 'coupons' => __( 'Coupon', DFRAPI_DOMAIN )
95 - ),
96 - 'operator' => $opIs
97 - ),
98 - array(
99 - 'title' => __( 'Currency', DFRAPI_DOMAIN ),
100 - 'name' => 'currency',
101 - 'input' => 'select',
102 - 'options' => array(
103 - 'USD' => 'USD',
104 - 'CAD' => 'CAD',
105 - 'GBP' => 'GBP',
106 - 'EUR' => 'EUR',
107 - 'AUD' => 'AUD',
108 - 'DKK' => 'DKK',
109 - 'SEK' => 'SEK',
110 - 'NOK' => 'NOK',
111 - 'CHF' => 'CHF',
112 - 'NZD' => 'NZD',
113 - 'TRY' => 'TRY',
114 - ),
115 - 'operator' => $opIsIsnt
116 - ),
117 - array(
118 - 'title' => __( 'Price', DFRAPI_DOMAIN ),
119 - 'name' => 'price',
120 - 'input' => 'range',
121 - 'operator' => $opRange
122 - ),
123 - array(
124 - 'title' => __( 'Sale Price', DFRAPI_DOMAIN ),
125 - 'name' => 'saleprice',
126 - 'input' => 'range',
127 - 'operator' => $opRange
128 - ),
129 - array(
130 - 'title' => __( 'Network', DFRAPI_DOMAIN ),
131 - 'name' => 'source_id',
132 - 'input' => 'network',
133 - 'operator' => $opIsIsnt
134 - ),
135 - array(
136 - 'title' => __( 'Merchant', DFRAPI_DOMAIN ),
137 - 'name' => 'merchant_id',
138 - 'input' => 'merchant',
139 - 'operator' => $opIsIsnt
140 - ),
141 - array(
142 - 'title' => __( 'On Sale', DFRAPI_DOMAIN ),
143 - 'name' => 'onsale',
144 - 'input' => 'none',
145 - 'operator' => $opYesNo
146 - ),
147 - array(
148 - 'title' => __( 'Discount', DFRAPI_DOMAIN ),
149 - 'name' => 'salediscount',
150 - 'input' => 'range',
151 - 'operator' => $opRange
152 - ),
153 - array(
154 - 'title' => __( 'Has Image', DFRAPI_DOMAIN ),
155 - 'name' => 'image',
156 - 'input' => 'none',
157 - 'operator' => $opYesNo
158 - ),
159 - array(
160 - 'title' => __( 'Last updated', DFRAPI_DOMAIN ),
161 - 'name' => 'time_updated',
162 - 'input' => 'range',
163 - 'operator' => array('lt' => 'before', 'gt' => 'after', 'between' => 'between'),
164 - ),
165 - array(
166 - 'title' => __( 'Limit', DFRAPI_DOMAIN ),
167 - 'name' => 'limit',
168 - 'input' => 'text',
169 - 'operator' => array('is' => 'is')
170 - ),
171 - array(
172 - 'title' => __( 'Sort By', DFRAPI_DOMAIN ),
173 - 'name' => 'sort',
174 - 'input' => 'none',
175 - 'operator' => $sortOpts
176 - ),
177 - array(
178 - 'title' => __( 'Exclude Duplicates', DFRAPI_DOMAIN ),
179 - 'name' => 'duplicates',
180 - 'input' => 'text',
181 - 'operator' => array(
182 - 'is' => __( 'matching these fields', DFRAPI_DOMAIN ),
183 - )
184 - )
185 - );
18 + $opFulltextExact = array_merge( $opFulltext, array(
19 + 'is' => __( 'is', 'datafeedr-api' )
20 + ) );
21 +
22 + $opRange = array(
23 + 'eq' => __( 'equal to', 'datafeedr-api' ),
24 + 'lt' => __( 'less than', 'datafeedr-api' ),
25 + 'lte' => __( 'less than or equal to', 'datafeedr-api' ),
26 + 'gt' => __( 'greater than', 'datafeedr-api' ),
27 + 'gte' => __( 'greater than or equal to', 'datafeedr-api' ),
28 + 'between' => __( 'between', 'datafeedr-api' )
29 + );
30 +
31 + $opIs = array(
32 + 'is' => __( 'is', 'datafeedr-api' )
33 + );
34 +
35 + $opIsIsnt = array(
36 + 'is' => __( 'is', 'datafeedr-api' ),
37 + 'is_not' => __( 'isn\'t', 'datafeedr-api' )
38 + );
39 +
40 + $opYesNo = array(
41 + 'yes' => __( 'yes', 'datafeedr-api' ),
42 + 'no' => __( 'no', 'datafeedr-api' )
43 + );
44 +
45 + $opInStock = array(
46 + 'yes_unknown' => __( 'yes or unknown', 'datafeedr-api' ),
47 + 'yes' => __( 'yes', 'datafeedr-api' ),
48 + 'no' => __( 'no', 'datafeedr-api' ),
49 + );
50 +
51 + $sortOpts = array(
52 + '' => __( 'Relevance', 'datafeedr-api' ),
53 + '+price' => __( 'Price Ascending', 'datafeedr-api' ),
54 + '-price' => __( 'Price Descending', 'datafeedr-api' ),
55 + '+saleprice' => __( 'Sale Price Ascending', 'datafeedr-api' ),
56 + '-saleprice' => __( 'Sale Price Descending', 'datafeedr-api' ),
57 + '+finalprice' => __( 'Final Price Ascending', 'datafeedr-api' ),
58 + '-finalprice' => __( 'Final Price Descending', 'datafeedr-api' ),
59 + '+salediscount' => __( 'Discount Ascending', 'datafeedr-api' ),
60 + '-salediscount' => __( 'Discount Descending', 'datafeedr-api' ),
61 + '+merchant' => __( 'Merchant', 'datafeedr-api' ),
62 + '+time_updated' => __( 'Last Updated Ascending', 'datafeedr-api' ),
63 + '-time_updated' => __( 'Last Updated Descending', 'datafeedr-api' ),
64 + '+_id' => __( 'Product ID Ascending', 'datafeedr-api' ),
65 + '-_id' => __( 'Product ID Descending', 'datafeedr-api' ),
66 + );
67 +
68 + return array(
69 + array(
70 + 'title' => __( 'Any Field', 'datafeedr-api' ),
71 + 'name' => 'any',
72 + 'input' => 'text',
73 + 'operator' => $opFulltext,
74 + 'help' => $this->help( 'any' )
75 + ),
76 + array(
77 + 'title' => __( 'Product Name', 'datafeedr-api' ),
78 + 'name' => 'name',
79 + 'input' => 'text',
80 + 'operator' => $opFulltextExact,
81 + 'help' => $this->help( 'name' )
82 + ),
83 + array(
84 + 'title' => __( 'Product ID', 'datafeedr-api' ),
85 + 'name' => 'id',
86 + 'input' => 'text',
87 + 'operator' => $opIsIsnt,
88 + 'help' => $this->help( 'id' )
89 + ),
90 + array(
91 + 'title' => __( 'Barcode', 'datafeedr-api' ),
92 + 'name' => 'barcode',
93 + 'input' => 'text',
94 + 'operator' => $opIsIsnt,
95 + 'help' => $this->help( 'barcode' )
96 + ),
97 + array(
98 + 'title' => __( 'Brand', 'datafeedr-api' ),
99 + 'name' => 'brand',
100 + 'input' => 'text',
101 + 'operator' => $opFulltextExact,
102 + 'help' => $this->help( 'brand' )
103 + ),
104 + array(
105 + 'title' => __( 'Color', 'datafeedr-api' ),
106 + 'name' => 'color',
107 + 'input' => 'text',
108 + 'operator' => $opFulltextExact,
109 + 'help' => $this->help( 'color' )
110 + ),
111 + array(
112 + 'title' => __( 'Material', 'datafeedr-api' ),
113 + 'name' => 'material',
114 + 'input' => 'text',
115 + 'operator' => $opFulltextExact,
116 + 'help' => $this->help( 'material' )
117 + ),
118 + array(
119 + 'title' => __( 'Size', 'datafeedr-api' ),
120 + 'name' => 'size',
121 + 'input' => 'text',
122 + 'operator' => $opFulltextExact,
123 + 'help' => $this->help( 'size' )
124 + ),
125 + array(
126 + 'title' => __( 'Gender', 'datafeedr-api' ),
127 + 'name' => 'gender',
128 + 'input' => 'text',
129 + 'operator' => $opFulltextExact,
130 + 'help' => $this->help( 'gender' )
131 + ),
132 + array(
133 + 'title' => __( 'SKU', 'datafeedr-api' ),
134 + 'name' => 'sku',
135 + 'input' => 'text',
136 + 'operator' => $opFulltextExact,
137 + 'help' => $this->help( 'sku' )
138 + ),
139 + array(
140 + 'title' => __( 'Condition', 'datafeedr-api' ),
141 + 'name' => 'condition',
142 + 'input' => 'text',
143 + 'operator' => $opFulltextExact,
144 + 'help' => $this->help( 'condition' )
145 + ),
146 + array(
147 + 'title' => __( 'Description', 'datafeedr-api' ),
148 + 'name' => 'description',
149 + 'input' => 'text',
150 + 'operator' => $opFulltext,
151 + 'help' => $this->help( 'description' )
152 + ),
153 + array(
154 + 'title' => __( 'Tags', 'datafeedr-api' ),
155 + 'name' => 'tags',
156 + 'input' => 'text',
157 + 'operator' => array(
158 + 'in' => __( 'contain', 'datafeedr-api' ),
159 + 'not_in' => __( 'don\'t contain', 'datafeedr-api' )
160 + ),
161 + 'help' => $this->help( 'tags' )
162 + ),
163 + array(
164 + 'title' => __( 'Category', 'datafeedr-api' ),
165 + 'name' => 'category',
166 + 'input' => 'text',
167 + 'operator' => $opFulltext,
168 + 'help' => $this->help( 'category' )
169 + ),
170 + array(
171 + 'title' => __( 'Product Type', 'datafeedr-api' ),
172 + 'name' => 'type',
173 + 'input' => 'select',
174 + 'options' => array(
175 + 'products' => __( 'Product', 'datafeedr-api' ),
176 + 'coupons' => __( 'Coupon', 'datafeedr-api' )
177 + ),
178 + 'operator' => $opIs,
179 + 'help' => $this->help( 'type' )
180 + ),
181 + array(
182 + 'title' => __( 'Currency', 'datafeedr-api' ),
183 + 'name' => 'currency',
184 + 'input' => 'select',
185 + 'options' => array(
186 + 'AUD' => 'AUD',
187 + 'BRL' => 'BRL',
188 + 'CAD' => 'CAD',
189 + 'CHF' => 'CHF',
190 + 'CZK' => 'CZK',
191 + 'DKK' => 'DKK',
192 + 'EUR' => 'EUR',
193 + 'GBP' => 'GBP',
194 + 'INR' => 'INR',
195 + 'NOK' => 'NOK',
196 + 'NZD' => 'NZD',
197 + 'PLN' => 'PLN',
198 + 'SEK' => 'SEK',
199 + 'TRY' => 'TRY',
200 + 'USD' => 'USD',
201 + ),
202 + 'operator' => $opIsIsnt,
203 + 'help' => $this->help( 'currency' )
204 + ),
205 + array(
206 + 'title' => __( 'Price', 'datafeedr-api' ),
207 + 'name' => 'price',
208 + 'input' => 'range',
209 + 'operator' => $opRange,
210 + 'help' => $this->help( 'price' )
211 + ),
212 + array(
213 + 'title' => __( 'Sale Price', 'datafeedr-api' ),
214 + 'name' => 'saleprice',
215 + 'input' => 'range',
216 + 'operator' => $opRange,
217 + 'help' => $this->help( 'saleprice' )
218 + ),
219 + array(
220 + 'title' => __( 'Final Price', 'datafeedr-api' ),
221 + 'name' => 'finalprice',
222 + 'input' => 'range',
223 + 'operator' => $opRange,
224 + 'help' => $this->help( 'finalprice' )
225 + ),
226 + array(
227 + 'title' => __( 'Discount', 'datafeedr-api' ),
228 + 'name' => 'salediscount',
229 + 'input' => 'range',
230 + 'operator' => $opRange,
231 + 'help' => $this->help( 'salediscount' )
232 + ),
233 + array(
234 + 'title' => __( 'Network', 'datafeedr-api' ),
235 + 'name' => 'source_id',
236 + 'input' => 'network',
237 + 'operator' => $opIsIsnt,
238 + 'help' => $this->help( 'source_id' )
239 + ),
240 + array(
241 + 'title' => __( 'Merchant', 'datafeedr-api' ),
242 + 'name' => 'merchant_id',
243 + 'input' => 'merchant',
244 + 'operator' => $opIsIsnt,
245 + 'help' => $this->help( 'merchant_id' )
246 + ),
247 + array(
248 + 'title' => __( 'On Sale', 'datafeedr-api' ),
249 + 'name' => 'onsale',
250 + 'input' => 'none',
251 + 'operator' => $opYesNo,
252 + 'help' => $this->help( 'onsale' )
253 + ),
254 + array(
255 + 'title' => __( 'In Stock', 'datafeedr-api' ),
256 + 'name' => 'instock',
257 + 'input' => 'none',
258 + 'operator' => $opInStock,
259 + 'help' => $this->help( 'instock' )
260 + ),
261 + array(
262 + 'title' => __( 'Stock Quantity', 'datafeedr-api' ),
263 + 'name' => 'stockquantity',
264 + 'input' => 'range',
265 + 'operator' => $opRange,
266 + 'help' => $this->help( 'instock' )
267 + ),
268 + array(
269 + 'title' => __( 'Has Direct URL', 'datafeedr-api' ),
270 + 'name' => 'direct_url',
271 + 'input' => 'none',
272 + 'operator' => $opYesNo,
273 + 'help' => $this->help( 'direct_url' )
274 + ),
275 + array(
276 + 'title' => __( 'Has Image', 'datafeedr-api' ),
277 + 'name' => 'image',
278 + 'input' => 'none',
279 + 'operator' => $opYesNo,
280 + 'help' => $this->help( 'image' )
281 + ),
282 + array(
283 + 'title' => __( 'Has Barcode', 'datafeedr-api' ),
284 + 'name' => 'has_barcode',
285 + 'input' => 'none',
286 + 'operator' => $opYesNo,
287 + 'help' => $this->help( 'has_barcode' )
288 + ),
289 + array(
290 + 'title' => __( 'Last Updated', 'datafeedr-api' ),
291 + 'name' => 'time_updated',
292 + 'input' => 'range',
293 + 'operator' => array( 'lt' => 'before', 'gt' => 'after', 'between' => 'between' ),
294 + 'help' => $this->help( 'time_updated' )
295 + ),
296 + array(
297 + 'title' => __( 'Limit', 'datafeedr-api' ),
298 + 'name' => 'limit',
299 + 'input' => 'text',
300 + 'operator' => array( 'is' => 'is' ),
301 + 'help' => $this->help( 'limit' )
302 + ),
303 + array(
304 + 'title' => __( 'Merchant Limit', 'datafeedr-api' ),
305 + 'name' => 'merchant_limit',
306 + 'input' => 'select',
307 + 'options' => array_filter( range( 0, 10 ), function ( $num ) {
308 + return $num != 0;
309 + } ),
310 + 'operator' => array( 'is' => 'is' ),
311 + 'help' => $this->help( 'merchant_limit' )
312 + ),
313 + array(
314 + 'title' => __( 'Sort By', 'datafeedr-api' ),
315 + 'name' => 'sort',
316 + 'input' => 'none',
317 + 'operator' => $sortOpts,
318 + 'help' => $this->help( 'sort' )
319 + ),
320 + array(
321 + 'title' => __( 'Exclude Duplicates', 'datafeedr-api' ),
322 + 'name' => 'duplicates',
323 + 'input' => 'text',
324 + 'operator' => array(
325 + 'is' => __( 'matching these fields', 'datafeedr-api' ),
326 + ),
327 + 'help' => $this->help( 'duplicates' )
328 + )
329 + );
186 330 }
187 331
188 - function defaults() {
189 - return array(
190 - 'any' => array('operator' => 'contain', 'value'=> ''),
191 - 'name' => array('operator' => 'contain', 'value'=> ''),
192 - 'type' => array('value'=> 'product'),
193 - 'currency' => array('value'=> 'USD'),
194 - 'price' => array('operator' => 'between', 'value'=> '0', 'value2' => '999999'),
195 - 'saleprice' => array('operator' => 'between', 'value'=> '0', 'value2' => '999999'),
196 - 'source_id' => array('value'=> array()),
197 - 'merchant_id' => array('value'=> array()),
198 - 'onsale' => array('value'=> '1'),
199 - 'image' => array('value'=> '1'),
200 - 'thumbnail' => array('value'=> '1'),
201 - 'time_updated' => array('operator' => 'lt', 'value'=> 'today'),
202 - 'limit' => array('value'=> 1000),
203 - );
204 - }
332 + function defaults() {
333 + return array(
334 + 'any' => array( 'operator' => 'match', 'value' => '' ),
335 + 'id' => array( 'operator' => 'is', 'value' => '' ),
336 + 'barcode' => array( 'operator' => 'is', 'value' => '' ),
337 + 'name' => array( 'operator' => 'match', 'value' => '' ),
338 + 'brand' => array( 'operator' => 'match', 'value' => '' ),
339 + 'color' => array( 'operator' => 'match', 'value' => '' ),
340 + 'material' => array( 'operator' => 'match', 'value' => '' ),
341 + 'size' => array( 'operator' => 'match', 'value' => '' ),
342 + 'gender' => array( 'operator' => 'match', 'value' => '' ),
343 + 'sku' => array( 'operator' => 'match', 'value' => '' ),
344 + 'condition' => array( 'operator' => 'match', 'value' => '' ),
345 + 'type' => array( 'value' => 'product' ),
346 + 'currency' => array( 'value' => 'USD' ),
347 + 'price' => array( 'operator' => 'between', 'value' => '0', 'value2' => '999999' ),
348 + 'saleprice' => array( 'operator' => 'between', 'value' => '0', 'value2' => '999999' ),
349 + 'source_id' => array( 'value' => array() ),
350 + 'merchant_id' => array( 'value' => array() ),
351 + 'onsale' => array( 'value' => '1' ),
352 + 'instock' => array( 'value' => 'yes_unknown' ),
353 + 'stockquantity' => array( 'operator' => 'between', 'value' => '0', 'value2' => '100' ),
354 + 'direct_url' => array( 'value' => '1' ),
355 + 'image' => array( 'value' => '1' ),
356 + 'has_barcode' => array( 'value' => '1' ),
357 + 'thumbnail' => array( 'value' => '1' ),
358 + 'time_updated' => array( 'operator' => 'lt', 'value' => 'today' ),
359 + 'limit' => array( 'value' => 1000 ),
360 + 'merchant_limit' => array( 'value' => 5 ),
361 + );
362 + }
205 363
206 364 public $useSelected;
207 365 public $prefix;
208 366
@@ -258,19 +416,19 @@
258 416 if(isset($selected[$net['_id']]))
259 417 $lst []= $net;
260 418 return $lst;
261 419 }
262 -
420 +
263 421 function groupClass($nid) {
264 - if (empty($nid)) { return ''; }
265 - $networks = $this->allNetworks();
266 - foreach($networks as $network) {
267 - if ($network['_id'] == $nid) {
268 - $name = str_replace( array( " ", "-", "." ), "", $network['group'] );
269 - $type = ( $network['type'] == 'coupons' ) ? '_coupons' : '';
270 - return 'network_logo_16x16_' . strtolower( $name . $type );
271 - }
272 - }
422 + if (empty($nid)) { return ''; }
423 + $networks = $this->allNetworks();
424 + foreach($networks as $network) {
425 + if ($network['_id'] == $nid) {
426 + $name = str_replace( array( " ", "-", "." ), "", $network['group'] );
427 + $type = ( $network['type'] == 'coupons' ) ? '_coupons' : '';
428 + return 'network_logo_16x16_' . strtolower( $name . $type );
429 + }
430 + }
273 431 }
274 432
275 433 function selectedMerchants() {
276 434 $selected = $this->get(get_option( 'dfrapi_merchants' ), 'ids');
@@ -286,13 +444,13 @@
286 444 }
287 445
288 446 function networksMerchantsPopup($kind, $value) {
289 447 $title = array(
290 - 'network' => __( 'Select Networks', DFRAPI_DOMAIN ),
291 - 'merchant' => __( 'Select Merchants', DFRAPI_DOMAIN )
448 + 'network' => __( 'Select Networks', 'datafeedr-api' ),
449 + 'merchant' => __( 'Select Merchants', 'datafeedr-api' )
292 450 );
293 - $clear = __( 'Clear search', DFRAPI_DOMAIN );
294 - $ok = __( 'OK', DFRAPI_DOMAIN );
451 + $clear = __( 'Clear search', 'datafeedr-api' );
452 + $ok = __( 'OK', 'datafeedr-api' );
295 453 $cells = "";
296 454
297 455 $all = ($kind == 'network') ?
298 456 ($this->useSelected ? $this->selectedNetworks() : $this->allNetworks()) :
@@ -298,13 +456,13 @@
298 456 ($this->useSelected ? $this->selectedNetworks() : $this->allNetworks()) :
299 457 $this->selectedMerchants();
300 458
301 459 foreach($all as $obj) {
302 - $id = $obj['_id'];
303 - $nid = ($kind == 'network') ? $obj['_id'] : $obj['source_id'];
304 - $group_class = $this->groupClass($nid);
460 + $id = absint($obj['_id']);
461 + $nid = absint(($kind == 'network') ? $obj['_id'] : $obj['source_id']);
462 + $group_class = esc_attr($this->groupClass($nid));
305 463
306 - $name = $obj['name'];
464 + $name = esc_html($obj['name']);
307 465 $checked = in_array($id, $value) ? "checked='checked'" : "";
308 466
309 467 $cells .= "
310 468 <div class='inline_frame_element nid_{$nid}'>
@@ -336,9 +494,9 @@
336 494 $all = ($kind == 'network') ? $this->allNetworks() : dfrapi_api_get_merchants_by_id($value);
337 495 $names = array();
338 496 foreach($all as $obj) {
339 497 if(in_array($obj['_id'], $value)) {
340 - $names []= "<span>{$obj['name']}</span>";
498 + $names []= '<span>' . esc_html($obj['name']) . '</span>';
341 499 if(count($names) >= $maxNames)
342 500 break;
343 501 }
344 502 }
@@ -343,9 +501,9 @@
343 501 }
344 502 }
345 503 $html = implode(', ', $names);
346 504 if(count($value) - count($names)) {
347 - $html .= ' ' . sprintf(__( 'and %s more', DFRAPI_DOMAIN ), count($value) - count($names));
505 + $html .= ' ' . sprintf(__( 'and %s more', 'datafeedr-api' ), count($value) - count($names));
348 506 }
349 507 return $html;
350 508 }
351 509
@@ -350,10 +508,10 @@
350 508 }
351 509
352 510 function chooseBox($kind, $field, $index, $value) {
353 511 $pfx = $this->inputPrefix($index);
354 - $value = implode(',', $this->ary($value));
355 - $choose = __( 'choose', DFRAPI_DOMAIN );
512 + $value = esc_attr(implode(',', $this->ary($value)));
513 + $choose = __( 'choose', 'datafeedr-api' );
356 514 return "
357 515 <div class='dfrapi_choose_box' rel='{$kind}'>
358 516 <span class='names'></span>
359 517 <a class='button choose_{$kind}'>{$choose}</a>
@@ -361,31 +519,49 @@
361 519 </div>
362 520 ";
363 521 }
364 522
365 - function ajaxHandler() {
366 - $command = $this->get($_POST, 'command');
367 - $value = $this->ary($this->get($_POST, 'value'));
368 - $this->useSelected = intval($this->get($_POST, 'useSelected', 1));
523 + function ajaxHandler() {
524 + $command = $this->get( $_POST, 'command' );
525 + $value = array_values( array_unique( array_filter( array_map( 'absint', $this->ary( $this->get( $_POST, 'value' ) ) ) ) ) );
526 + $this->useSelected = (int) $this->get( $_POST, 'useSelected', 1 );
369 527
370 - switch($command) {
371 - case "choose_network":
372 - return $this->networksMerchantsPopup('network', $value);
373 - case "choose_merchant":
374 - return $this->networksMerchantsPopup('merchant', $value);
375 - case "names_network":
376 - return $this->networksMerchantsNames('network', $value);
377 - case "names_merchant":
378 - return $this->networksMerchantsNames('merchant', $value);
379 - }
380 - return "";
381 - }
528 + if ( $command === 'choose_network' ) {
529 + return $this->networksMerchantsPopup( 'network', $value );
530 + }
382 531
532 + if ( $command === 'choose_merchant' ) {
533 + return $this->networksMerchantsPopup( 'merchant', $value );
534 + }
535 +
536 + if ( $command === 'names_network' ) {
537 + return $this->networksMerchantsNames( 'network', $value );
538 + }
539 +
540 + if ( $command === 'names_merchant' && ! empty( $value ) ) {
541 + return $this->networksMerchantsNames( 'merchant', $value );
542 + }
543 +
544 +// switch ( $command ) {
545 +// case "choose_network":
546 +// return $this->networksMerchantsPopup( 'network', $value );
547 +// case "choose_merchant":
548 +// return $this->networksMerchantsPopup( 'merchant', $value );
549 +// case "names_network":
550 +// return $this->networksMerchantsNames( 'network', $value );
551 +// case "names_merchant":
552 +// return $this->networksMerchantsNames( 'merchant', $value );
553 +// }
554 +
555 + return '';
556 + }
557 +
383 558 function renderField($field, $index, $params) {
384 559 $pfx = $this->inputPrefix($index);
385 560 $value = $this->get($params, 'value');
386 561 $operator = $this->get($params, 'operator');
387 562 $input = "";
563 + $percent_sign = ( isset( $field['name'] ) && $field['name'] == 'salediscount') ? '%' : '';
388 564
389 565 switch($field['input']) {
390 566 case 'text':
391 567 $value = htmlspecialchars($value);
@@ -397,11 +573,11 @@
397 573 break;
398 574 case 'range':
399 575 $value = htmlspecialchars($value);
400 576 $value2 = htmlspecialchars($this->get($params, 'value2'));
401 - $and = __( 'and', DFRAPI_DOMAIN );
577 + $and = __( 'and', 'datafeedr-api' );
402 578 $input = "
403 - <input class='short' name='{$pfx}[value]' type='text' value=\"$value\"/>
579 + <input class='short' name='{$pfx}[value]' type='text' value=\"$value\"/>{$percent_sign}
404 580 <span class='value2' style='display:none'>
405 581 $and
406 582 <input class='short' name='{$pfx}[value2]' type='text' value=\"$value2\" />
407 583 </span>
@@ -448,15 +624,17 @@
448 624 <div class='valuewrapper'>
449 625 <div class='value'>{$input}</div>
450 626 </div>
451 627 <div class='plusminus'><a class='minus'></a> </div>
452 - <div class='field'><select name='{$pfx}[field]' style='width: 95%'>{$fieldOpts}</select></div>
628 + <div class='field'><select name='{$pfx}[field]' style='width: 140px'>{$fieldOpts}</select><a href='#' class='dfrapi_search_help'>?</a></div>
453 629 <div class='operator'>{$operator}</div>
630 + <div class='clearfix'></div>
631 + <div class='help' style='display:none;'><a href='#' class='dfrapi_search_help'><span class='dashicons dashicons-no'> </span></a>{$field['help']}</div>
454 632 </div>
455 633 ";
456 634 }
457 635
458 - function render($prefix, $query, $useSelected=TRUE) {
636 + function render($prefix, $query, $useSelected=true) {
459 637 $this->prefix = $prefix;
460 638 $this->useSelected = intval($useSelected);
461 639 if(!$query)
462 640 $query = array(
@@ -478,9 +656,9 @@
478 656 $field = $this->get($fieldMap, $this->get($params, 'field'));
479 657 if(!$field)
480 658 continue;
481 659 $fieldUsed[$field['name']] = 1;
482 - $form .= $this->renderRow($field, $index++, $params, TRUE);
660 + $form .= $this->renderRow($field, $index++, $params, true);
483 661 }
484 662 $show = ($index == 0); // if none shown, show the first
485 663 foreach($fieldMap as $field) {
486 664 $name = $field['name'];
@@ -489,10 +667,10 @@
489 667 $show = FALSE;
490 668 }
491 669 }
492 670
493 - $loading = __( 'Loading, please wait', DFRAPI_DOMAIN );
494 - $add = __( 'add filter', DFRAPI_DOMAIN );
671 + $loading = __( 'Loading, please wait', 'datafeedr-api' );
672 + $add = __( 'add filter', 'datafeedr-api' );
495 673 return "
496 674 <div id='dfrapi_search_form'>
497 675 <input type='hidden' id='dfrapi_useSelected' value='{$this->useSelected}' />
498 676 <div id='dfprs_loading_content' style='display:none'>
@@ -513,9 +691,9 @@
513 691 return current($lst);
514 692 $lst = call_user_func_array($func, $lst);
515 693 return count($lst) ? $lst : NULL;
516 694 }
517 -
695 +
518 696 function idFilter($inList, $exList) {
519 697 $inList = $this->combineLists($inList, 'array_intersect');
520 698 $exList = $this->combineLists($exList, 'array_merge');
521 699
@@ -581,9 +759,17 @@
581 759 switch($fname) {
582 760 case 'any':
583 761 case 'name':
584 762 case 'brand':
763 + case 'color':
764 + case 'material':
765 + case 'size':
766 + case 'gender':
767 + case 'sku':
768 + case 'condition':
585 769 case 'description':
770 + case 'merchant':
771 + case 'source':
586 772 case 'category':
587 773 $s = $this->fulltextFilter($operator, $value);
588 774 if(!is_null($s[0])) {
589 775 $filters []= "{$fname} {$s[0]} {$s[1]}";
@@ -593,14 +779,22 @@
593 779 $operator = ($operator == 'in') ? "LIKE" : "!LIKE";
594 780 $filters []= "{$fname} {$operator} {$value}";
595 781 break;
596 782 case 'currency':
597 - $filters []= "{$fname} = {$value}";
783 + $op = ($operator == 'is') ? '=' : '!=';
784 + $filters []= "{$fname} $op {$value}";
598 785 break;
786 + case 'id':
787 + case 'barcode':
788 + $op = ($operator == 'is') ? 'IN' : '!IN';
789 + $filters []= "{$fname} $op {$value}";
790 + break;
599 791 case 'price':
792 + case 'finalprice':
600 793 case 'saleprice':
601 794 case 'salediscount':
602 - $conv = $fname == 'salediscount' ? 'intval' : 'dfrapi_price_to_int';
795 + case 'stockquantity':
796 + $conv = in_array( $fname, [ 'salediscount', 'stockquantity' ] ) ? 'intval' : 'dfrapi_price_to_int';
603 797 $value = $conv($value);
604 798 switch($operator) {
605 799 case 'between':
606 800 $value2 = $conv($value2);
@@ -606,14 +800,23 @@
606 800 $value2 = $conv($value2);
607 801 $filters []= "{$fname} > {$value}";
608 802 $filters []= "{$fname} < {$value2}";
609 803 break;
804 + case 'eq':
805 + $filters []= "{$fname} = {$value}";
806 + break;
610 807 case 'lt':
611 808 $filters []= "{$fname} < {$value}";
612 809 break;
810 + case 'lte':
811 + $filters []= "{$fname} <= {$value}";
812 + break;
613 813 case 'gt':
614 814 $filters []= "{$fname} > {$value}";
615 815 break;
816 + case 'gte':
817 + $filters []= "{$fname} >= {$value}";
818 + break;
616 819 }
617 820 break;
618 821 case 'source_id':
619 822 case 'merchant_id':
@@ -631,13 +834,32 @@
631 834 case 'onsale':
632 835 $value = ($operator == 'yes') ? '1' : '0';
633 836 $filters []= "{$fname} = {$value}";
634 837 break;
635 - case 'image':
636 - case 'thumbnail':
838 + case 'instock':
839 + if ( $operator == 'yes' ) {
840 + $filters [] = "{$fname} = 1";
841 + break;
842 + } elseif ( $operator == 'no' ) {
843 + $filters [] = "{$fname} = 0";
844 + break;
845 + } else {
846 + $filters [] = "{$fname} > 0";
847 + break;
848 + }
849 + case 'direct_url':
637 850 $operator = ($operator == 'yes') ? '!EMPTY' : 'EMPTY';
638 - $filters []= "image {$operator}";
851 + $filters []= "{$fname} {$operator}";
639 852 break;
853 + case 'image':
854 + case 'thumbnail':
855 + $operator = ($operator == 'yes') ? '!EMPTY' : 'EMPTY';
856 + $filters []= "image {$operator}";
857 + break;
858 + case 'has_barcode':
859 + $operator = ( $operator === 'yes') ? '!EMPTY' : 'EMPTY';
860 + $filters []= "barcode {$operator}";
861 + break;
640 862 case 'time_updated':
641 863 $value = @date('Y-m-d H:i:s', strtotime($value));
642 864 switch($operator) {
643 865 case 'between':
@@ -664,12 +886,251 @@
664 886
665 887 $s = $this->idFilter($selected['in:merchant_id'], $selected['ex:merchant_id']);
666 888 if(is_null($s))
667 889 return array('error' => 'No merchants selected');
668 - if(!is_null($s[0]))
669 - $filters []= "merchant_id {$s[0]} ". implode(',', $s[1]);
890 + if(!is_null($s[0])) {
891 + $m = implode(',', $s[1]);
892 + if ($m)
893 + $filters []= "merchant_id {$s[0]} $m";
894 + }
670 895
671 896 return $filters;
672 897
673 898 }
899 +
900 + function help_tip($tip) {
901 + return '
902 + <div class="dfrapi_search_tip">
903 + <span class="dashicons dashicons-lightbulb"></span>
904 + <p>
905 + <strong>' . __( 'TIP:', 'datafeedr-api' ) . '</strong> ' .
906 + $tip . '
907 + </p>
908 + </div>
909 + ';
910 + }
911 +
912 + function help_operators() {
913 + return '
914 + <p>
915 + <span class="dashicons dashicons-info"></span>
916 + <em>
917 + <a href="https://datafeedrapi.helpscoutdocs.com/article/216-search-operators" target="_blank">' . __('Learn more', 'datafeedr-api' ) . '</a> ' .
918 + __('about advanced uses of this field.', 'datafeedr-api' ) . '
919 + </em>
920 + </p>
921 + ';
922 + }
923 +
924 + function help($field) {
925 +
926 + $help = array();
927 +
928 + // Any
929 + $help['any'] = '<h3>' . __('Any Field', 'datafeedr-api' ) . '</h3>';
930 + $help['any'] .= '<p>' . __( 'Search all indexed text fields at once to return a broad set of results.', 'datafeedr-api' ) . '</p>';
931 + $help['any'] .= '<p>' . __( 'The fields listed below are indexed as text fields and searchable using Any Field. Image, currency, and price fields are not searched.', 'datafeedr-api' ) . '</p>';
932 + $help['any'] .= '<p><em>' . __( '*Note that not all merchants and networks provide every field. ', 'datafeedr-api' ) . '</em></p>';
933 + $help['any'] .= '<p>' . __( 'Fields searched using Any Field:', 'datafeedr-api' ) . '</p>';
934 + $help['any'] .= '<table width="100%" border="0" style="margin-bottom:20px"><tr><td width="33%" valign="top">accommodationtype<br />address<br />artist<br />author<br />bestsellers<br />brand<br />category<br />city<br />color<br />commissiontype<br />condition<br />country<br />county<br />description<br />destination<br />discount</td><td width="33%" valign="top">discounttype<br />ean<br />fabric<br />featured<br />flavour<br />gender<br />genre<br />isbn<br />language<br />location<br />manufacturer<br />manufacturerid<br />material<br />size<br />gender<br />model<br />mpn<br />name</td><td width="33%" valign="top">offercode<br />offertype<br />platform<br />productnumber<br />promo<br />publisher<br />rating<br />region<br />size<br />sku<br />stars<br />state<br />subcategory<br />tags<br />upc<br />weight</td></tr></table>';
935 + $help['any'] .= $this->help_operators();
936 +
937 + // Name
938 + $help['name'] = '<h3>' . __('Product Name', 'datafeedr-api' ) . '</h3>';
939 + $help['name'] .= '<p>' . __( 'Search by product name to narrow your results.', 'datafeedr-api' ) . '</p>';
940 + $help['name'] .= $this->help_tip( __( 'Some merchants include color, size, gender, product codes, sale information and promotions in the product name field.', 'datafeedr-api' ) );
941 + $help['name'] .= $this->help_operators();
942 +
943 + // ID
944 + $help['id'] = '<h3>' . __('Product ID', 'datafeedr-api' ) . '</h3>';
945 + $help['id'] .= '<p>' . __( 'Search by Product ID to find specific products.', 'datafeedr-api' ) . '</p>';
946 + $help['id'] .= $this->help_tip( __( 'Separate each product ID with a comma "," to search for multiple products by their IDs.<br /><br />Example: <strong>4088900432286084, 8177000167015036, 2651801988581531</strong>', 'datafeedr-api' ) );
947 + $help['id'] .= '<p>' . __( 'Product IDs are assigned by Datafeedr and are not related to any IDs merchants use to identify their products. Each product in the Datafeedr product database has a unique Product ID.', 'datafeedr-api' ) . '</p>';
948 +// $help['id'] .= $this->help_operators();
949 +
950 + // Barcode
951 + $help['barcode'] = '<h3>' . __('Barcode', 'datafeedr-api' ) . '</h3>';
952 + $help['barcode'] .= '<p>' . __( 'Search for products by their barcode (ie. EAN, UPC or GTIN value).', 'datafeedr-api' ) . '</p>';
953 + $help['barcode'] .= $this->help_tip( __( 'Separate each barcode with a comma "," to search for multiple products by their barcodes.<br /><br />Example: <strong>889169871993, 889169900167, 889169488559</strong>', 'datafeedr-api' ) );
954 + $help['barcode'] .= '<p>' . __( 'The Barcode search filter ignores leading zeros. Therefore, searching for <strong>889169871993</strong> and searching for <strong>00889169871993</strong> will return the same results.', 'datafeedr-api' ) . '</p>';
955 +
956 + // Brand
957 + $help['brand'] = '<h3>' . __('Brand', 'datafeedr-api' ) . '</h3>';
958 + $help['brand'] .= '<p>' . __( 'Search by brand name to get specific results. Not every item has a brand name.', 'datafeedr-api' ) . '</p>';
959 + $help['brand'] .= $this->help_tip( __( 'Enter the shorter version of a brand name in this field. Omit words such as "Incorporated", "Limited" and their abbreviations like Inc., Ltd. and so on.', 'datafeedr-api' ) );
960 + $help['brand'] .= $this->help_operators();
961 +
962 + // Color
963 + $help['color'] = '<h3>' . __('Color', 'datafeedr-api' ) . '</h3>';
964 + $help['color'] .= '<p>' . __( 'Search by color to get specific results. Not every item has a color field.', 'datafeedr-api' ) . '</p>';
965 +
966 + // Material
967 + $help['material'] = '<h3>' . __('Material', 'datafeedr-api' ) . '</h3>';
968 + $help['material'] .= '<p>' . __( 'Search by material to get specific results. Not every item has a material field.', 'datafeedr-api' ) . '</p>';
969 +
970 + // Size
971 + $help['size'] = '<h3>' . __('Size', 'datafeedr-api' ) . '</h3>';
972 + $help['size'] .= '<p>' . __( 'Search by size to get specific results. Not every item has a size field.', 'datafeedr-api' ) . '</p>';
973 +
974 + // Gender
975 + $help['gender'] = '<h3>' . __('Gender', 'datafeedr-api' ) . '</h3>';
976 + $help['gender'] .= '<p>' . __( 'Search by gender to get specific results. Not every item has a gender field.', 'datafeedr-api' ) . '</p>';
977 +
978 + // SKU
979 + $help['sku'] = '<h3>' . __('SKU', 'datafeedr-api' ) . '</h3>';
980 + $help['sku'] .= '<p>' . __( 'Search by SKU to get specific results. Not every item has a SKU field.', 'datafeedr-api' ) . '</p>';
981 +
982 + // Condition
983 + $help['condition'] = '<h3>' . __('Condition', 'datafeedr-api' ) . '</h3>';
984 + $help['condition'] .= '<p>' . __( 'Search by condition to get specific results. Not every item has a condition field.', 'datafeedr-api' ) . '</p>';
985 +
986 + // Description
987 + $help['description'] = '<h3>' . __('Description', 'datafeedr-api' ) . '</h3>';
988 + $help['description'] .= '<p>' . __( 'Search the description field for product attributes such as size, color, material, gender or usage.', 'datafeedr-api' ) . '</p>';
989 + $help['description'] .= $this->help_tip( __( 'Most merchants provide a product description. Some product details may only appear in the description and not in any other field. However, some merchants duplicate the product name or product code in the description field without supplying additional details or leave the product description blank.', 'datafeedr-api' ) );
990 + $help['description'] .= $this->help_operators();
991 +
992 + // Tags
993 + $help['tags'] = '<h3>' . __('Tags', 'datafeedr-api' ) . '</h3>';
994 + $help['tags'] .= '<p>' . __( 'Limit search results based on product tag and keyword information.', 'datafeedr-api' ) . '</p>';
995 + $help['tags'] .= $this->help_tip( __( 'This field contains data from various keyword-related fields provided by the merchant. This field does not always exist.', 'datafeedr-api' ) );
996 +
997 + // Category
998 + $help['category'] = '<h3>' . __('Category', 'datafeedr-api' ) . '</h3>';
999 + $help['category'] .= '<p>' . __( 'Limit search results based on category information.', 'datafeedr-api' ) . '</p>';
1000 + $help['category'] .= $this->help_tip( __( 'This field contains data from various category-related fields provided by the merchant. This field does not always exist.', 'datafeedr-api' ) );
1001 + $help['category'] .= $this->help_operators();
1002 +
1003 + // Type
1004 + $help['type'] = '<h3>' . __('Product Type', 'datafeedr-api' ) . '</h3>';
1005 + $help['type'] .= '<p>' . __( 'Limit your search results to one type of item, either Product or Coupon.', 'datafeedr-api' ) . '</p>';
1006 + $help['type'] .= $this->help_tip( __( 'In order to use this filter, you must have already selected merchants that provide that type of item. For example, if you choose "Product type: Coupon" but have not selected any merchants that offer coupons, your search will return an error.', 'datafeedr-api' ) );
1007 +
1008 + // Currency
1009 + $help['currency'] = '<h3>' . __('Currency', 'datafeedr-api' ) . '</h3>';
1010 + $help['currency'] .= '<p>' . __( 'Limit your search results to items with a specific currency code.', 'datafeedr-api' ) . '</p>';
1011 + $help['currency'] .= $this->help_tip( __( 'Selecting a currency code is one way to limit your search results to items from a specific country. However, not every item has been given a currency code value by the merchant. Items without a currency code will be excluded from your search results.', 'datafeedr-api' ) );
1012 +
1013 + // Price
1014 + $help['price'] = '<h3>' . __('Price', 'datafeedr-api' ) . '</h3>';
1015 + $help['price'] .= '<p>' . __( 'Filter your search results based on price. Return products less than, greater than, or within a price range that you set.', 'datafeedr-api' ) . '</p>';
1016 + $help['price'] .= $this->help_tip( __( 'This field does not search on sale price. If you set a price range to less than 30, you will exclude an item with a regular price of 40 that is on sale for less than 30.', 'datafeedr-api' ) );
1017 +
1018 + // Sale Price
1019 + $help['saleprice'] = '<h3>' . __('Sale Price', 'datafeedr-api' ) . '</h3>';
1020 + $help['saleprice'] .= '<p>' . __( 'Filter your search results based on sale price. Return items less than, greater than, or within a sale price range that you set.', 'datafeedr-api' ) . '</p>';
1021 + $help['saleprice'] .= $this->help_tip( __( 'This field does not search on regular price. If you set a sale price range to between 50 and 100, an item with a sale price of 40 will be excluded even if it\'s regular price matches the range you set.', 'datafeedr-api' ) );
1022 +
1023 + // Final Price
1024 + $help['finalprice'] = '<h3>' . __('Final Price', 'datafeedr-api' ) . '</h3>';
1025 + $help['finalprice'] .= '<p>' . __( 'Filter your search results based on the final price. Return items less than, greater than, or within a sale price range that you set.', 'datafeedr-api' ) . '</p>';
1026 + $help['finalprice'] .= $this->help_tip( __( 'The final price is the lower price when comparing the regular price and sale price field.', 'datafeedr-api' ) );
1027 +
1028 + // Discount
1029 + $help['salediscount'] = '<h3>' . __('Discount', 'datafeedr-api' ) . '</h3>';
1030 + $help['salediscount'] .= '<p>' . __( 'Limit your search results to items with a specified discount. Enter the number in terms of percentage (1 - 100) to indicate a discount less than, greater than, or between a given range. You do not need to enter the percentage sign.', 'datafeedr-api' ) . '</p>';
1031 + $help['salediscount'] .= $this->help_tip( __( 'To display, for example, only products that are on sale for a discount of 20% or more, choose the "greater than" operator and type "19".', 'datafeedr-api' ) );
1032 +
1033 + // Network
1034 + $help['source_id'] = '<h3>' . __('Network', 'datafeedr-api' ) . '</h3>';
1035 + $help['source_id'] .= '<p>' . __( 'Limit your search results to items from one or more affiliate networks.', 'datafeedr-api' ) . '</p>';
1036 + $help['source_id'] .= $this->help_tip( __( 'Affiliate networks are generally country-specific. Using the Network filter is one way to limit your search results by country.', 'datafeedr-api' ) );
1037 +
1038 + // Merchant
1039 + $help['merchant_id'] = '<h3>' . __('Merchant', 'datafeedr-api' ) . '</h3>';
1040 + $help['merchant_id'] .= '<p>' . __( 'Limit your search results to items from one or more merchants.', 'datafeedr-api' ) . '</p>';
1041 + $help['merchant_id'] .= $this->help_tip( __( 'Using the Merchant filter is a quick way to exclude unrelated products and reduce the number of API requests made when building a Product Set. For example, if you are creating a Product Set related to cat products, exclude all merchants that only sell dog products.', 'datafeedr-api' ) );
1042 +
1043 + // On Sale
1044 + $help['onsale'] = '<h3>' . __('On Sale', 'datafeedr-api' ) . '</h3>';
1045 + $help['onsale'] .= '<p>' . __( 'Set this field to "<strong>yes</strong>" to return only items which are on sale. To exclude products which are on sale, set this field to "<strong>no</strong>".', 'datafeedr-api' ) . '</p>';
1046 +
1047 + // In Stock
1048 + $help['instock'] = '<h3>' . __('In Stock', 'datafeedr-api' ) . '</h3>';
1049 + $help['instock'] .= '<p>' . __( 'This allows you to filter products by stock status.', 'datafeedr-api' ) . '</p>';
1050 + $help['instock'] .= '<p>' . __( '<strong>yes or unknown</strong>: This will return products which are explicitly set as "in-stock" or products which have no field containing stock-related information.', 'datafeedr-api' ) . '</p>';
1051 + $help['instock'] .= '<p>' . __( '<strong>yes</strong>: This will only return products which are explicitly set as "in-stock".', 'datafeedr-api' ) . '</p>';
1052 + $help['instock'] .= '<p>' . __( '<strong>no</strong>: This will only return products which are explicitly set as NOT "in-stock".', 'datafeedr-api' ) . '</p>';
1053 + $help['instock'] .= $this->help_tip( __( 'Not all products contain stock-related information. Therefore selecting "yes or unknown" is the recommended choice when you want to find products which are "in-stock".', 'datafeedr-api' ) );
1054 +
1055 + // Stock Quantity
1056 + $help['instock'] = '<h3>' . __('Stock Quantity', 'datafeedr-api' ) . '</h3>';
1057 + $help['instock'] .= '<p>' . __( 'This allows you to filter products by the number of products in stock.', 'datafeedr-api' ) . '</p>';
1058 + $help['instock'] .= '<p>' . __( '<strong>NOTE</strong>: Not all products have a "Stock Quantity" value. Therefore, searching for a product with a stock quantity greater than or equal to "0" will eliminate all products which have an unknow "Stock Quantity".', 'datafeedr-api' ) . '</p>';
1059 + $help['instock'] .= '<p>' . __( 'To search for products which either have a stock quantity in a specific range AND also include products which do not have a stock quantity value, use the "between" search option and enter "-1" for the first option and enter the upper limit (ie. 100) for the second value.', 'datafeedr-api' ) . '</p>';
1060 +
1061 + // Has Direct URL
1062 + $help['direct_url'] = '<h3>' . __('Has Direct URL', 'datafeedr-api' ) . '</h3>';
1063 + $help['direct_url'] .= '<p>' . __( 'Limit your search results to items which have a direct URL (or which don\'t).', 'datafeedr-api' ) . '</p>';
1064 + $help['direct_url'] .= $this->help_tip( __( 'A "Direct URL" is a URL directly to the product page on the merchant\'s website. By default, the "Direct URL" is never used as the URL in your "Buy" links. However, if you need the products in your store to contain a "Direct URL" to the product page on the merchants\' websites, then you should use this filter. This is most useful if you are using Skimlinks (or similar service) to generate your affiliate links instead of the affiliate networks.', 'datafeedr-api' ) );
1065 +
1066 + // Has Image
1067 + $help['image'] = '<h3>' . __('Has Image', 'datafeedr-api' ) . '</h3>';
1068 + $help['image'] .= '<p>' . __( 'Limit your search results to items which have an image (or which don\'t).', 'datafeedr-api' ) . '</p>';
1069 + $help['image'] .= $this->help_tip( __( 'Sometimes the image URL in the merchant\'s data feed is broken. Items with broken images will still return in search results even though there appears to be no image.', 'datafeedr-api' ) );
1070 +
1071 + // Has Barcode
1072 + $help['has_barcode'] = '<h3>' . __('Has Barcode', 'datafeedr-api' ) . '</h3>';
1073 + $help['has_barcode'] .= '<p>' . __( 'Limit your search results to products which have a barcode (ie. a UPC, EAN or GTIN value).', 'datafeedr-api' ) . '</p>';
1074 +
1075 + // Last Updated
1076 + $help['time_updated'] = '<h3>' . __('Last Updated', 'datafeedr-api' ) . '</h3>';
1077 + $help['time_updated'] .= '<p>' . __( 'Filter products by the last time they were updated by the merchant. Enter an English textual datetime description using PHP\'s <a href="http://www.php.net/strtotime" target="_blank">strtotime()</a> function.', 'datafeedr-api' ) . '</p>';
1078 + $help['time_updated'] .= '<h3>' . __('Examples', 'datafeedr-api' ) . '</h3>';
1079 + $help['time_updated'] .= '<p>';
1080 + $help['time_updated'] .= '<tt>' . __('last week', 'datafeedr-api' ) . '</tt><br />';
1081 + $help['time_updated'] .= '<tt>' . __('2 days ago', 'datafeedr-api' ) . '</tt><br />';
1082 + $help['time_updated'] .= '<tt>' . __('1 month ago', 'datafeedr-api' ) . '</tt>';
1083 + $help['time_updated'] .= '</p>';
1084 + $help['time_updated'] .= '<p>' . __( '', 'datafeedr-api' ) . '</p>';
1085 + $help['time_updated'] .= $this->help_tip( __( 'An item\'s Last Updated date will not change if the merchant does not change any product information during a data feed update.', 'datafeedr-api' ) );
1086 +
1087 + // Limit
1088 + $help['limit'] = '<h3>' . __('Limit', 'datafeedr-api' ) . '</h3>';
1089 + $help['limit'] .= '<p>' . __( 'Limit the number of items returned in your search results. The maximum number of products that can be returned is 10,000.', 'datafeedr-api' ) . '</p>';
1090 + $help['limit'] .= $this->help_tip( __( 'Limiting the number of products returned helps reduce the number of API requests made during searching and updating Product Sets.', 'datafeedr-api' ) );
1091 +
1092 + // Merchant Limit
1093 + $help['merchant_limit'] = '<h3>' . __('Merchant Limit', 'datafeedr-api' ) . '</h3>';
1094 + $help['merchant_limit'] .= '<p>' . __( 'Limit the number of items returned per merchant. The number must be between 1 and 10.', 'datafeedr-api' ) . '</p>';
1095 + $help['merchant_limit'] .= $this->help_tip( __( 'This is useful to use when you have one merchant which has many products that match your search but other merchants have fewer of those same products and you want equal distribution between all merchants.', 'datafeedr-api' ) );
1096 +
1097 + // Sort By
1098 + $help['sort'] = '<h3>' . __('Sort By', 'datafeedr-api' ) . '</h3>';
1099 + $help['sort'] .= '<p>' . __( 'Change the sort criteria by which items are displayed in your search results.', 'datafeedr-api' ) . '</p>';
1100 + $help['sort'] .= $this->help_tip( __( 'By default, search results are sorted by relevance. You can change that to sort by price, sale price, discount, or last updated date in ascending order (lowest to highest) or descending order (highest to lowest). You can also sort by merchant, which lists items alphabetically by merchant name.', 'datafeedr-api' ) );
1101 +
1102 + // Exclude Duplicates
1103 + $help['duplicates'] = '<h3>' . __('Exclude Duplicates', 'datafeedr-api' ) . '</h3>';
1104 + $help['duplicates'] .= '<p>' . __( 'Exclude items that contain identical product names, image URLs, etc. Enter one or more terms from the list below. Separate terms by a space (meaning AND) or | (pipe symbol, meaning OR).', 'datafeedr-api' ) . '<br />';
1105 + $help['duplicates'] .= '<p>' . __( 'Enter one of these terms to exclude duplicates matching these fields:', 'datafeedr-api' ) . '<br />';
1106 + $help['duplicates'] .= '<tt>' . __('name', 'datafeedr-api' ) . '</tt><br />';
1107 + $help['duplicates'] .= '<tt>' . __('brand', 'datafeedr-api' ) . '</tt><br />';
1108 + $help['duplicates'] .= '<tt>' . __('description', 'datafeedr-api' ) . '</tt><br />';
1109 + $help['duplicates'] .= '<tt>' . __('currency', 'datafeedr-api' ) . '</tt><br />';
1110 + $help['duplicates'] .= '<tt>' . __('price', 'datafeedr-api' ) . '</tt><br />';
1111 + $help['duplicates'] .= '<tt>' . __('saleprice', 'datafeedr-api' ) . '</tt><br />';
1112 + $help['duplicates'] .= '<tt>' . __('source_id', 'datafeedr-api' ) . '</tt><br />';
1113 + $help['duplicates'] .= '<tt>' . __('merchant_id', 'datafeedr-api' ) . '</tt><br />';
1114 + $help['duplicates'] .= '<tt>' . __('direct_url', 'datafeedr-api' ) . '</tt><br />';
1115 + $help['duplicates'] .= '<tt>' . __('onsale', 'datafeedr-api' ) . '</tt><br />';
1116 + $help['duplicates'] .= '<tt>' . __('image', 'datafeedr-api' ) . '</tt><br />';
1117 + $help['duplicates'] .= '<tt>' . __('thumbnail', 'datafeedr-api' ) . '</tt>';
1118 + $help['duplicates'] .= '</p>';
1119 + $help['duplicates'] .= '<h3>' . __('Examples', 'datafeedr-api' ) . '</h3>';
1120 + $help['duplicates'] .= '<p>';
1121 + $help['duplicates'] .= '<tt>' . __('image</tt> - Exclude items which have the same image URL.', 'datafeedr-api' ) . '<br />';
1122 + $help['duplicates'] .= '<tt>' . __('name image</tt> - Exclude items with the same name AND the same image URL.', 'datafeedr-api' ) . '<br />';
1123 + $help['duplicates'] .= '<tt>' . __('name|image</tt> - Exclude items with the same name OR the same image URL.', 'datafeedr-api' ) . '<br />';
1124 + $help['duplicates'] .= '<tt>' . __('merchant_id name|image</tt> - Exclude items which have the same merchant id AND (product name OR image URL).', 'datafeedr-api' ) . '<br />';
1125 + $help['duplicates'] .= '</p>';
1126 + $help['duplicates'] .= $this->help_tip( __( 'By excluding duplicates, you will eliminate all but one item. For example, if 20 products have identical image URLs and you exclude duplicates matching the <strong>image</strong> field, <em>one</em> item will be returned and 19 items will be excluded.', 'datafeedr-api' ) );
1127 +
1128 + if (isset($help[$field])) {
1129 + return $help[$field];
1130 + } else {
1131 + return '';
1132 + }
1133 +
1134 + } // help()
674 1135
675 1136 }