Printful Integration for WooCommerce - Version 2.0.3

Version Description

Fixed various minor issues, enabled localization, Improved compatibility with WC 3.4.3

Download this release

Release Info

Developer printful
Plugin Icon 128x128 Printful Integration for WooCommerce
Version 2.0.3
Comparing to
See all releases

Code changes from version 2.0.2 to 2.0.3

assets/css/settings.css CHANGED
@@ -37,4 +37,10 @@
37
  display: none;
38
  float: left;
39
  line-height: 24px;
 
 
 
 
 
 
40
  }
37
  display: none;
38
  float: left;
39
  line-height: 24px;
40
+ }
41
+
42
+ .printful-setting-group .carrier-type {
43
+ font-weight: bold;
44
+ padding: 20px 0;
45
+ display: block;
46
  }
i18n/languages/printful.pot ADDED
@@ -0,0 +1,531 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "POT-Creation-Date: 2018-04-26 13:49+0300\n"
5
+ "PO-Revision-Date: 2018-04-26 13:50+0300\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "Language: en\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 2.0.7\n"
13
+ "X-Poedit-Basepath: ../..\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-KeywordsList: __;_e;_n;_x;_ex;_nx;esc_attr__;esc_attr_e;esc_attr_x;"
16
+ "esc_html__;esc_html_e;esc_html_x;_n_noop;_nx_noop;translate_nooped_plural\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: includes/class-printful-admin-dashboard.php:130
20
+ msgid "Loading your stats..."
21
+ msgstr ""
22
+
23
+ #: includes/class-printful-admin-dashboard.php:136
24
+ msgid "Loading your orders..."
25
+ msgstr ""
26
+
27
+ #: includes/class-printful-admin-settings.php:14
28
+ msgid "Printful store API key"
29
+ msgstr ""
30
+
31
+ #: includes/class-printful-admin-settings.php:17
32
+ msgid "Your store's Printful API key. Create it in the Prinful dashboard"
33
+ msgstr ""
34
+
35
+ #: includes/class-printful-admin-settings.php:21
36
+ msgid "Calculate sales tax"
37
+ msgstr ""
38
+
39
+ #: includes/class-printful-admin-settings.php:23
40
+ msgid "Calculated for all products shipped to North Carolina and California"
41
+ msgstr ""
42
+
43
+ #: includes/class-printful-admin-settings.php:27
44
+ msgid "Disable SSL"
45
+ msgstr ""
46
+
47
+ #: includes/class-printful-admin-settings.php:29
48
+ msgid ""
49
+ "Use HTTP instead of HTTPS to connect to the Printful API (may be required if "
50
+ "the plugin does not work for some hosting configurations)"
51
+ msgstr ""
52
+
53
+ #: includes/class-printful-admin-settings.php:120
54
+ msgid "Carriers & Services"
55
+ msgstr ""
56
+
57
+ #: includes/class-printful-admin-settings.php:121
58
+ msgid ""
59
+ "You can specify here which shipping carriers are available for this store.\n"
60
+ "\n"
61
+ "\t\t\t Uncheck the ones you want to disable. If you leave “Flat rate” "
62
+ "checked it means that any order where flat rate was selected can still ship "
63
+ "with any carrier and service."
64
+ msgstr ""
65
+
66
+ #: includes/class-printful-admin-settings.php:127
67
+ msgid "You need to be connected to Printful API to edit carrier settings!"
68
+ msgstr ""
69
+
70
+ #: includes/class-printful-admin-status.php:22
71
+ msgid "Connection to Printful API"
72
+ msgstr ""
73
+
74
+ #: includes/class-printful-admin-status.php:23
75
+ msgid "Is your store successfully connected to Printful API?"
76
+ msgstr ""
77
+
78
+ #: includes/class-printful-admin-status.php:27
79
+ msgid "Printful API key is set"
80
+ msgstr ""
81
+
82
+ #: includes/class-printful-admin-status.php:28
83
+ msgid ""
84
+ "Your store needs access to Printful API to use most of it's features like "
85
+ "shipping rates, tax rates and other settings."
86
+ msgstr ""
87
+
88
+ #: includes/class-printful-admin-status.php:32
89
+ msgid "WordPress Permalinks"
90
+ msgstr ""
91
+
92
+ #: includes/class-printful-admin-status.php:33
93
+ msgid ""
94
+ "WooCommerce API will not work unless your permalinks in Settings > "
95
+ "Permalinks are set up correctly. Make sure you that they are NOT set to "
96
+ "\"plain\"."
97
+ msgstr ""
98
+
99
+ #: includes/class-printful-admin-status.php:37
100
+ msgid "WordPress version"
101
+ msgstr ""
102
+
103
+ #: includes/class-printful-admin-status.php:38
104
+ msgid ""
105
+ "WordPress should always be updated to the latest version. Updates can be "
106
+ "installed from your WordPress admin dashboard."
107
+ msgstr ""
108
+
109
+ #: includes/class-printful-admin-status.php:42
110
+ msgid "WooCommerce API enabled"
111
+ msgstr ""
112
+
113
+ #: includes/class-printful-admin-status.php:43
114
+ msgid ""
115
+ "Your site needs to enbable WooCommerce API so that Printful can connect to "
116
+ "it."
117
+ msgstr ""
118
+
119
+ #: includes/class-printful-admin-status.php:47
120
+ msgid "WooCommerce Webhooks"
121
+ msgstr ""
122
+
123
+ #: includes/class-printful-admin-status.php:48
124
+ msgid ""
125
+ "Printful requires WooCommerce webhooks to be set up to quickly capture you "
126
+ "incoming orders, products updates etc."
127
+ msgstr ""
128
+
129
+ #: includes/class-printful-admin-status.php:52
130
+ msgid "WooCommerce API keys are set"
131
+ msgstr ""
132
+
133
+ #: includes/class-printful-admin-status.php:53
134
+ msgid ""
135
+ "Printful needs access to your WooCommerce API for the integration to work - "
136
+ "otherwise we can't sync your store, push or pull your products etc."
137
+ msgstr ""
138
+
139
+ #: includes/class-printful-admin-status.php:57
140
+ msgid "WooCommerce authentication URL access"
141
+ msgstr ""
142
+
143
+ #: includes/class-printful-admin-status.php:58
144
+ msgid ""
145
+ "Some hosts have unnecessarily intrusive security checks in place that "
146
+ "prevent WooCommerce API authentication from working (mod_security rule "
147
+ "#1234234). If this check fails, you will not be able authorize Printful app."
148
+ msgstr ""
149
+
150
+ #: includes/class-printful-admin-status.php:62
151
+ msgid "WordPress remote requests"
152
+ msgstr ""
153
+
154
+ #: includes/class-printful-admin-status.php:63
155
+ msgid ""
156
+ "WordPress needs to be able to connect to Printful server to call webhooks. "
157
+ "If this check fails, contact your hosting support."
158
+ msgstr ""
159
+
160
+ #: includes/class-printful-admin-status.php:67
161
+ msgid "Recent store sync errors"
162
+ msgstr ""
163
+
164
+ #: includes/class-printful-admin-status.php:68
165
+ msgid ""
166
+ "Printful will connect to your store's API regularly and sync your latest "
167
+ "products, orders etc. If there have been any recent issues with sync, this "
168
+ "check will fail."
169
+ msgstr ""
170
+
171
+ #: includes/class-printful-admin-status.php:72
172
+ msgid "Write permissions"
173
+ msgstr ""
174
+
175
+ #: includes/class-printful-admin-status.php:73
176
+ msgid ""
177
+ "Make the uploads directory writable. This is required for mockup generator "
178
+ "product push to work correctly. Contact your hosting provider if you need "
179
+ "help with this."
180
+ msgstr ""
181
+
182
+ #: includes/class-printful-admin-status.php:77
183
+ msgid "PHP memory limit"
184
+ msgstr ""
185
+
186
+ #: includes/class-printful-admin-status.php:78
187
+ msgid ""
188
+ "Set PHP allocated memory limit to at least 128mb. Contact your hosting "
189
+ "provider if you need help with this."
190
+ msgstr ""
191
+
192
+ #: includes/class-printful-admin-status.php:82
193
+ msgid "PHP script time limit"
194
+ msgstr ""
195
+
196
+ #: includes/class-printful-admin-status.php:83
197
+ msgid ""
198
+ "Set PHP script execution time limit to at least 30 seconds. This is required "
199
+ "to successfully push products with many variants. Contact your hosting "
200
+ "provider if you need help with this."
201
+ msgstr ""
202
+
203
+ #: includes/class-printful-admin-status.php:92
204
+ msgid "W3 Total Cache DB Cache"
205
+ msgstr ""
206
+
207
+ #: includes/class-printful-admin-status.php:93
208
+ msgid ""
209
+ "If you are using W3 Total Cache, the database caching feature needs to be "
210
+ "disabled since it can cause issues with product push to store."
211
+ msgstr ""
212
+
213
+ #: includes/class-printful-admin-status.php:98
214
+ msgid "WP SpamShield"
215
+ msgstr ""
216
+
217
+ #: includes/class-printful-admin-status.php:99
218
+ msgid ""
219
+ "If you are using WP SpamShield, you might experiance problems connecting to "
220
+ "Printful and pushing products."
221
+ msgstr ""
222
+
223
+ #: includes/class-printful-admin-status.php:104
224
+ msgid "Remove Print Aura plugin"
225
+ msgstr ""
226
+
227
+ #: includes/class-printful-admin-status.php:105
228
+ msgid "Print Aura plugin is known to cause issues so it needs to be removed."
229
+ msgstr ""
230
+
231
+ #: includes/class-printful-admin-status.php:144
232
+ msgid "Testing your store (this may take up to 30 seconds)..."
233
+ msgstr ""
234
+
235
+ #: includes/class-printful-admin-support.php:36
236
+ msgid "Building support report (this may take up to 30 seconds)..."
237
+ msgstr ""
238
+
239
+ #: includes/class-printful-admin-support.php:68
240
+ msgid "##### Printful Checklist #####\n"
241
+ msgstr ""
242
+
243
+ #: includes/class-printful-admin.php:71 includes/class-printful-admin.php:112
244
+ msgid "Dashboard"
245
+ msgstr ""
246
+
247
+ #: includes/class-printful-admin.php:106
248
+ msgid "Settings"
249
+ msgstr ""
250
+
251
+ #: includes/class-printful-admin.php:107 includes/templates/order-table.php:12
252
+ #: includes/templates/order-table.php:58 includes/templates/status-table.php:21
253
+ #: includes/templates/status-table.php:49
254
+ msgid "Status"
255
+ msgstr ""
256
+
257
+ #: includes/class-printful-admin.php:108
258
+ msgid "Support"
259
+ msgstr ""
260
+
261
+ #: includes/class-printful-admin.php:114 includes/templates/connect.php:29
262
+ msgid "Connect"
263
+ msgstr ""
264
+
265
+ #: includes/class-printful-admin.php:142
266
+ msgid " issue"
267
+ msgstr ""
268
+
269
+ #: includes/class-printful-api-resource.php:35
270
+ msgid "No size chart was provided"
271
+ msgstr ""
272
+
273
+ #: includes/class-printful-api-resource.php:41
274
+ msgid "The product ID is invalid"
275
+ msgstr ""
276
+
277
+ #: includes/class-printful-api-resource.php:47
278
+ msgid "The product is not found"
279
+ msgstr ""
280
+
281
+ #: includes/class-printful-api-resource.php:53
282
+ msgid "You do not have permission to edit the size chart"
283
+ msgstr ""
284
+
285
+ #: includes/class-printful-shipping.php:49
286
+ msgid "Enable/Disable"
287
+ msgstr ""
288
+
289
+ #: includes/class-printful-shipping.php:51
290
+ msgid "Enable this shipping method"
291
+ msgstr ""
292
+
293
+ #: includes/class-printful-shipping.php:55
294
+ msgid "Disable Woocommerce rates"
295
+ msgstr ""
296
+
297
+ #: includes/class-printful-shipping.php:57
298
+ msgid "Disable standard Woocommerce rates for products fulfilled by Printful"
299
+ msgstr ""
300
+
301
+ #: includes/class-printful-shipping.php:61
302
+ msgid "Show Printful warnings"
303
+ msgstr ""
304
+
305
+ #: includes/class-printful-shipping.php:63
306
+ msgid "Display Printful status messages if rate API request fails"
307
+ msgstr ""
308
+
309
+ #: includes/class-printful-size-chart-tab.php:27
310
+ msgid "Size chart"
311
+ msgstr ""
312
+
313
+ #: includes/class-printful-size-chart-tab.php:39
314
+ #: includes/class-printful-size-chart-tab.php:53
315
+ msgid "Size Chart"
316
+ msgstr ""
317
+
318
+ #: includes/templates/connect.php:5
319
+ msgid "Connect to Printful"
320
+ msgstr ""
321
+
322
+ #: includes/templates/connect.php:12
323
+ msgid "To connect your store to Printful, fix the following errors:"
324
+ msgstr ""
325
+
326
+ #: includes/templates/connect.php:25
327
+ msgid ""
328
+ "You're almost done! Just 2 more steps to have your WooCommerce store "
329
+ "connected to Printful for automatic order fulfillment."
330
+ msgstr ""
331
+
332
+ #: includes/templates/error.php:1
333
+ msgid "Error:"
334
+ msgstr ""
335
+
336
+ #: includes/templates/order-table.php:9 includes/templates/order-table.php:55
337
+ msgid "Order"
338
+ msgstr ""
339
+
340
+ #: includes/templates/order-table.php:10 includes/templates/order-table.php:56
341
+ msgid "Date"
342
+ msgstr ""
343
+
344
+ #: includes/templates/order-table.php:11 includes/templates/order-table.php:57
345
+ msgid "From"
346
+ msgstr ""
347
+
348
+ #: includes/templates/order-table.php:13 includes/templates/order-table.php:59
349
+ msgid "Total"
350
+ msgstr ""
351
+
352
+ #: includes/templates/order-table.php:14 includes/templates/order-table.php:60
353
+ msgid "Actions"
354
+ msgstr ""
355
+
356
+ #: includes/templates/order-table.php:46
357
+ msgid "Open in Printful"
358
+ msgstr ""
359
+
360
+ #: includes/templates/order-table.php:67
361
+ msgid ""
362
+ "Once your store gets some Printful product orders, they will be shown here!"
363
+ msgstr ""
364
+
365
+ #: includes/templates/quick-links.php:6
366
+ msgid "Orders"
367
+ msgstr ""
368
+
369
+ #: includes/templates/quick-links.php:10
370
+ msgid "File library"
371
+ msgstr ""
372
+
373
+ #: includes/templates/quick-links.php:14
374
+ msgid "Stores"
375
+ msgstr ""
376
+
377
+ #: includes/templates/quick-links.php:18
378
+ msgid "Reports"
379
+ msgstr ""
380
+
381
+ #: includes/templates/quick-links.php:22
382
+ msgid "My Account"
383
+ msgstr ""
384
+
385
+ #: includes/templates/quick-links.php:26
386
+ msgid "Billing"
387
+ msgstr ""
388
+
389
+ #: includes/templates/quick-links.php:30
390
+ msgid "Notifications"
391
+ msgstr ""
392
+
393
+ #: includes/templates/setting-submit.php:2
394
+ msgid "Save changes"
395
+ msgstr ""
396
+
397
+ #: includes/templates/setting-submit.php:9
398
+ msgid "Saved successfully"
399
+ msgstr ""
400
+
401
+ #: includes/templates/setting-submit.php:13
402
+ msgid "Saving settings failed"
403
+ msgstr ""
404
+
405
+ #: includes/templates/shipping-notification.php:2
406
+ msgid "Printful Shipping"
407
+ msgstr ""
408
+
409
+ #: includes/templates/shipping-notification.php:3
410
+ msgid "To enable/disable Printful shipping for your store go to"
411
+ msgstr ""
412
+
413
+ #: includes/templates/shipping-notification.php:3
414
+ msgid "WooCommerce Shipping settings"
415
+ msgstr ""
416
+
417
+ #: includes/templates/stats.php:7 includes/templates/stats.php:20
418
+ #: includes/templates/stats.php:33
419
+ msgid "ORDER"
420
+ msgstr ""
421
+
422
+ #: includes/templates/stats.php:10
423
+ msgid "today"
424
+ msgstr ""
425
+
426
+ #: includes/templates/stats.php:23
427
+ msgid "last 7 days"
428
+ msgstr ""
429
+
430
+ #: includes/templates/stats.php:35 includes/templates/stats.php:42
431
+ msgid "last 28 days"
432
+ msgstr ""
433
+
434
+ #: includes/templates/stats.php:42
435
+ msgid "PROFIT"
436
+ msgstr ""
437
+
438
+ #: includes/templates/status-report.php:2
439
+ msgid "Copy the box content below and add it to your support message"
440
+ msgstr ""
441
+
442
+ #: includes/templates/status-report.php:4
443
+ msgid "Copy"
444
+ msgstr ""
445
+
446
+ #: includes/templates/status-table.php:4
447
+ msgid ""
448
+ "Looks like the everything is set up correctly and Printful integration "
449
+ "should work as intended."
450
+ msgstr ""
451
+
452
+ #: includes/templates/status-table.php:10
453
+ msgid ""
454
+ "There are errors with your store setup that may cause the Printful "
455
+ "integration to not work as intended!"
456
+ msgstr ""
457
+
458
+ #: includes/templates/status-table.php:19
459
+ #: includes/templates/status-table.php:47
460
+ msgid "Name"
461
+ msgstr ""
462
+
463
+ #: includes/templates/status-table.php:20
464
+ #: includes/templates/status-table.php:48
465
+ msgid "Description"
466
+ msgstr ""
467
+
468
+ #: includes/templates/status-table.php:34
469
+ msgid "OK"
470
+ msgstr ""
471
+
472
+ #: includes/templates/status-table.php:36
473
+ msgid "WARNING"
474
+ msgstr ""
475
+
476
+ #: includes/templates/status-table.php:38
477
+ msgid "FAIL"
478
+ msgstr ""
479
+
480
+ #: includes/templates/status-table.php:54
481
+ msgid ""
482
+ "Warnings are issued when the test was unable to come to a definite "
483
+ "conclusion or if the result was passable, but not ideal."
484
+ msgstr ""
485
+
486
+ #: includes/templates/support-info.php:4
487
+ msgid "Need help? Get in touch!"
488
+ msgstr ""
489
+
490
+ #: includes/templates/support-info.php:5
491
+ msgid ""
492
+ "Email, call, text, or visit us. We've got support teams in the USA and "
493
+ "Europe to make sure we're there when you need us."
494
+ msgstr ""
495
+
496
+ #: includes/templates/support-info.php:5
497
+ msgid "We'd love to hear from you."
498
+ msgstr ""
499
+
500
+ #: includes/templates/support-info.php:7
501
+ msgid "Contact support"
502
+ msgstr ""
503
+
504
+ #: includes/templates/support-info.php:12
505
+ msgid "Read our FAQs"
506
+ msgstr ""
507
+
508
+ #: includes/templates/support-info.php:13
509
+ msgid "Getting started made easy – read the FAQs to jumpstart your business."
510
+ msgstr ""
511
+
512
+ #: includes/templates/support-info.php:13
513
+ msgid ""
514
+ "Whether you're a video tutorial fan or prefer the written answers – we've "
515
+ "got it covered!"
516
+ msgstr ""
517
+
518
+ #: includes/templates/support-info.php:15
519
+ msgid "See Printful FAQ"
520
+ msgstr ""
521
+
522
+ #: includes/templates/support-info.php:20
523
+ #: includes/templates/support-info.php:23
524
+ msgid "Integration help"
525
+ msgstr ""
526
+
527
+ #: includes/templates/support-info.php:21
528
+ msgid ""
529
+ "Are you experiencing technical issues? Solve them on your own by reading "
530
+ "these helpful guides and video tutorials."
531
+ msgstr ""
includes/class-printful-admin-dashboard.php CHANGED
@@ -127,13 +127,13 @@ class Printful_Admin_Dashboard {
127
  if ( $stats ) {
128
  Printful_Admin::load_template( 'stats', array( 'stats' => $stats ) );
129
  } else {
130
- Printful_Admin::load_template( 'ajax-loader', array( 'action' => 'get_printful_stats', 'message' => 'Loading your stats...' ) );
131
  }
132
 
133
  if ($orders) {
134
  Printful_Admin::load_template( 'order-table', array( 'orders' => $orders ) );
135
  } else {
136
- Printful_Admin::load_template( 'ajax-loader', array( 'action' => 'get_printful_orders', 'message' => 'Loading your orders...' ) );
137
  }
138
 
139
  } else {
@@ -255,14 +255,19 @@ class Printful_Admin_Dashboard {
255
  global $wpdb;
256
 
257
  // Get the API key
258
- $search = "AND description LIKE '%" . esc_sql( $wpdb->esc_like( wc_clean( self::API_KEY_SEARCH_STRING ) ) ) . "%' ";
259
- $query = "SELECT truncated_key FROM {$wpdb->prefix}woocommerce_api_keys WHERE 1 = 1 {$search} ORDER BY key_id DESC LIMIT 1";
260
- $consumer_key = $wpdb->get_var( $query );
 
 
 
 
261
 
262
  //if not found by description, it was probably manually created. try the last used key instead
263
  if ( ! $consumer_key ) {
264
- $query = "SELECT truncated_key FROM {$wpdb->prefix}woocommerce_api_keys ORDER BY key_id DESC LIMIT 1";
265
- $consumer_key = $wpdb->get_var( $query );
 
266
  }
267
 
268
  return $consumer_key;
127
  if ( $stats ) {
128
  Printful_Admin::load_template( 'stats', array( 'stats' => $stats ) );
129
  } else {
130
+ Printful_Admin::load_template( 'ajax-loader', array( 'action' => 'get_printful_stats', 'message' => __( 'Loading your stats...', 'printful' ) ) );
131
  }
132
 
133
  if ($orders) {
134
  Printful_Admin::load_template( 'order-table', array( 'orders' => $orders ) );
135
  } else {
136
+ Printful_Admin::load_template( 'ajax-loader', array( 'action' => 'get_printful_orders', 'message' => __( 'Loading your orders...', 'printful' ) ) );
137
  }
138
 
139
  } else {
255
  global $wpdb;
256
 
257
  // Get the API key
258
+ $printfulKey = '%' . esc_sql( $wpdb->esc_like( wc_clean( self::API_KEY_SEARCH_STRING ) ) ) . '%';
259
+ $consumer_key = $wpdb->get_var(
260
+ $wpdb->prepare(
261
+ "SELECT truncated_key FROM {$wpdb->prefix}woocommerce_api_keys WHERE description LIKE %s ORDER BY key_id DESC LIMIT 1",
262
+ $printfulKey
263
+ )
264
+ );
265
 
266
  //if not found by description, it was probably manually created. try the last used key instead
267
  if ( ! $consumer_key ) {
268
+ $consumer_key = $wpdb->get_var(
269
+ "SELECT truncated_key FROM {$wpdb->prefix}woocommerce_api_keys ORDER BY key_id DESC LIMIT 1"
270
+ );
271
  }
272
 
273
  return $consumer_key;
includes/class-printful-admin-settings.php CHANGED
@@ -7,27 +7,30 @@ class Printful_Admin_Settings {
7
  const CARRIER_TYPE_STANDARD = 'standard';
8
  const CARRIER_TYPE_EXPEDITED = 'expedited';
9
 
10
- public static $integration_fields = array(
11
- 'printful_key' => array(
12
- 'title' => 'Printful store API key',
13
- 'type' => 'text',
14
- 'desc_tip' => true,
15
- 'description' => 'Your store\'s Printful API key. Create it in the Prinful dashboard',
16
- 'default' => false,
17
- ),
18
- 'calculate_tax' => array(
19
- 'title' => 'Calculate sales tax',
20
- 'type' => 'checkbox',
21
- 'label' => 'Calculated for all products shipped to North Carolina and California',
22
- 'default' => 'no',
23
- ),
24
- 'disable_ssl' => array(
25
- 'title' => 'Disable SSL',
26
- 'type' => 'checkbox',
27
- 'label' => 'Use HTTP instead of HTTPS to connect to the Printful API (may be required if the plugin does not work for some hosting configurations)',
28
- 'default' => 'no',
29
- ),
30
- );
 
 
 
31
 
32
  /**
33
  * @return Printful_Admin_Settings
@@ -57,7 +60,7 @@ class Printful_Admin_Settings {
57
 
58
  Printful_Admin::load_template( 'header', array( 'tabs' => Printful_Admin::get_tabs() ) );
59
 
60
- echo '<form method="post" name="printful_settings" action="' . admin_url( 'admin-ajax.php?action=save_printful_settings' ) . '">';
61
 
62
  //integration settings
63
  $integration_settings = $this->setup_integration_fields();
@@ -96,7 +99,7 @@ class Printful_Admin_Settings {
96
  $integration_settings = array(
97
  'title' => 'Integration settings',
98
  'description' => '',
99
- 'settings' => self::$integration_fields,
100
  );
101
 
102
  foreach ( $integration_settings['settings'] as $key => $setting ) {
@@ -114,53 +117,53 @@ class Printful_Admin_Settings {
114
  public function setup_carrier_fields() {
115
 
116
  $carrier_settings = array(
117
- 'title' => 'Carriers & Services',
118
- 'description' => "You can specify here which shipping carriers are available for this store.\n
119
- Uncheck the ones you want to disable. If you leave “Flat rate” checked it means that any order where flat rate was selected can still ship with any carrier and service.",
120
  'settings' => array(),
121
  );
122
 
123
  if ( ! Printful_Integration::instance()->is_connected() ) {
124
- $carrier_settings['description'] = 'You need to be connected to Printful API to edit carrier settings!';
125
  return $carrier_settings;
126
  }
127
 
128
- $carriers = Printful_Carriers::instance()->carriers;
129
- if ( empty( $carriers ) ) {
130
- return false;
131
  }
132
 
133
  $standard = array();
134
  $expedited = array();
135
 
136
- foreach ( $carriers as $carrier ) {
137
-
138
- $item = array(
139
- 'title' => false,
140
- 'type' => 'checkbox',
141
- 'label' => $carrier['title'] . ' <i>' . $carrier['subtitle'] . '</i>',
142
- 'default' => 'yes',
143
- 'value' => ( $carrier['status'] == 'on' ? 'yes' : 'no' ),
144
- );
145
-
146
- if ( $carrier['type'] == self::CARRIER_TYPE_STANDARD ) {
147
- $standard[ $carrier['carrier_id'] ] = $item;
148
- } else {
149
- $expedited[ $carrier['carrier_id'] ] = $item;
150
- }
151
- }
152
-
153
- $carrier_settings['settings'][ self::CARRIER_TYPE_STANDARD ] = array(
154
- 'title' => 'Standard shipping',
155
- 'type' => 'checkbox-group',
156
- 'items' => $standard,
157
- );
158
-
159
- $carrier_settings['settings'][ self::CARRIER_TYPE_EXPEDITED ] = array(
160
- 'title' => 'Expedited shipping',
161
- 'type' => 'checkbox-group',
162
- 'items' => $expedited,
163
- );
164
 
165
  return $carrier_settings;
166
  }
@@ -171,35 +174,35 @@ class Printful_Admin_Settings {
171
  */
172
  public function prepare_carriers() {
173
 
174
- $carriers = Printful_Carriers::instance()->carriers;
175
 
176
- if ( empty( $carriers ) ) {
177
  return false;
178
  }
179
 
180
- $standard = ( ! empty( $_POST[ self::CARRIER_TYPE_STANDARD ] ) ? $_POST[ self::CARRIER_TYPE_STANDARD ] : array() );
181
- $expedited = ( ! empty( $_POST[ self::CARRIER_TYPE_EXPEDITED ] ) ? $_POST[ self::CARRIER_TYPE_EXPEDITED ] : array() );
182
 
183
- $saved_carriers = array_merge( $standard, $expedited );
184
 
185
- if ( empty( $saved_carriers ) ) {
186
  return false;
187
  }
188
 
189
  $request_body = array();
190
 
191
- foreach ( $carriers as $carrier ) {
192
- $status = 'off';
193
- if ( in_array( $carrier['carrier_id'], $saved_carriers ) ) {
194
- $status = 'on';
195
- }
196
- $request_body[] = array(
197
- 'carrier_id' => $carrier['carrier_id'],
198
- 'status' => $status,
199
- );
200
- }
201
-
202
- return $request_body;
203
  }
204
 
205
  /**
@@ -226,7 +229,7 @@ class Printful_Admin_Settings {
226
  $options = array();
227
 
228
  //build save options list
229
- foreach ( self::$integration_fields as $key => $field ) {
230
 
231
  if ( $field['type'] == 'checkbox' ) {
232
  if ( isset( $_POST[ $key ] ) ) {
7
  const CARRIER_TYPE_STANDARD = 'standard';
8
  const CARRIER_TYPE_EXPEDITED = 'expedited';
9
 
10
+ public static function getIntegrationFields()
11
+ {
12
+ return array(
13
+ 'printful_key' => array(
14
+ 'title' => __( 'Printful store API key', 'printful' ),
15
+ 'type' => 'text',
16
+ 'desc_tip' => true,
17
+ 'description' => __( 'Your store\'s Printful API key. Create it in the Prinful dashboard', 'printful' ),
18
+ 'default' => false,
19
+ ),
20
+ 'calculate_tax' => array(
21
+ 'title' => __( 'Calculate sales tax', 'printful' ),
22
+ 'type' => 'checkbox',
23
+ 'label' => __( 'Calculated for all products shipped to North Carolina and California', 'printful' ),
24
+ 'default' => 'no',
25
+ ),
26
+ 'disable_ssl' => array(
27
+ 'title' => __( 'Disable SSL', 'printful' ),
28
+ 'type' => 'checkbox',
29
+ 'label' => __( 'Use HTTP instead of HTTPS to connect to the Printful API (may be required if the plugin does not work for some hosting configurations)', 'printful' ),
30
+ 'default' => 'no',
31
+ ),
32
+ );
33
+ }
34
 
35
  /**
36
  * @return Printful_Admin_Settings
60
 
61
  Printful_Admin::load_template( 'header', array( 'tabs' => Printful_Admin::get_tabs() ) );
62
 
63
+ echo '<form method="post" name="printful_settings" action="' . esc_url( admin_url( 'admin-ajax.php?action=save_printful_settings' ) ) . '">';
64
 
65
  //integration settings
66
  $integration_settings = $this->setup_integration_fields();
99
  $integration_settings = array(
100
  'title' => 'Integration settings',
101
  'description' => '',
102
+ 'settings' => self::getIntegrationFields(),
103
  );
104
 
105
  foreach ( $integration_settings['settings'] as $key => $setting ) {
117
  public function setup_carrier_fields() {
118
 
119
  $carrier_settings = array(
120
+ 'title' => __( 'Carriers & Services', 'printful' ),
121
+ 'description' => __( "You can specify here which shipping carriers are available for this store.\n
122
+ Uncheck the ones you want to disable. If you leave “Flat rate” checked it means that any order where flat rate was selected can still ship with any carrier and service.", 'printful' ),
123
  'settings' => array(),
124
  );
125
 
126
  if ( ! Printful_Integration::instance()->is_connected() ) {
127
+ $carrier_settings['description'] = __('You need to be connected to Printful API to edit carrier settings!', 'printful' );
128
  return $carrier_settings;
129
  }
130
 
131
+ $carriers = Printful_Carriers::instance()->carriers;
132
+ if ( empty( $carriers ) ) {
133
+ return false;
134
  }
135
 
136
  $standard = array();
137
  $expedited = array();
138
 
139
+ foreach ( $carriers as $carrier ) {
140
+
141
+ $item = array(
142
+ 'title' => false,
143
+ 'type' => 'checkbox',
144
+ 'label' => $carrier['title'] . ' <i>' . $carrier['subtitle'] . '</i>',
145
+ 'default' => 'yes',
146
+ 'value' => ( $carrier['status'] == 'on' ? 'yes' : 'no' ),
147
+ );
148
+
149
+ if ( $carrier['type'] == self::CARRIER_TYPE_STANDARD ) {
150
+ $standard[ $carrier['carrier_id'] ] = $item;
151
+ } else {
152
+ $expedited[ $carrier['carrier_id'] ] = $item;
153
+ }
154
+ }
155
+
156
+ $carrier_settings['settings'][ self::CARRIER_TYPE_STANDARD ] = array(
157
+ 'title' => 'Standard shipping',
158
+ 'type' => 'checkbox-group',
159
+ 'items' => $standard,
160
+ );
161
+
162
+ $carrier_settings['settings'][ self::CARRIER_TYPE_EXPEDITED ] = array(
163
+ 'title' => 'Expedited shipping',
164
+ 'type' => 'checkbox-group',
165
+ 'items' => $expedited,
166
+ );
167
 
168
  return $carrier_settings;
169
  }
174
  */
175
  public function prepare_carriers() {
176
 
177
+ $carriers = Printful_Carriers::instance()->carriers;
178
 
179
+ if ( empty( $carriers ) ) {
180
  return false;
181
  }
182
 
183
+ $standard = ( ( ! empty( $_POST[ self::CARRIER_TYPE_STANDARD ] ) && wp_verify_nonce( $_POST['_wpnonce'], 'printful_settings' ) ) ? $_POST[ self::CARRIER_TYPE_STANDARD ] : array() );
184
+ $expedited = ( ( ! empty( $_POST[ self::CARRIER_TYPE_EXPEDITED ] ) && wp_verify_nonce( $_POST['_wpnonce'], 'printful_settings' ) ) ? $_POST[ self::CARRIER_TYPE_EXPEDITED ] : array() );
185
 
186
+ $saved_carriers = array_merge( $standard, $expedited );
187
 
188
+ if ( empty( $saved_carriers ) ) {
189
  return false;
190
  }
191
 
192
  $request_body = array();
193
 
194
+ foreach ( $carriers as $carrier ) {
195
+ $status = 'off';
196
+ if ( in_array( $carrier['carrier_id'], $saved_carriers ) ) {
197
+ $status = 'on';
198
+ }
199
+ $request_body[] = array(
200
+ 'carrier_id' => $carrier['carrier_id'],
201
+ 'status' => $status,
202
+ );
203
+ }
204
+
205
+ return $request_body;
206
  }
207
 
208
  /**
229
  $options = array();
230
 
231
  //build save options list
232
+ foreach ( self::getIntegrationFields() as $key => $field ) {
233
 
234
  if ( $field['type'] == 'checkbox' ) {
235
  if ( isset( $_POST[ $key ] ) ) {
includes/class-printful-admin-status.php CHANGED
@@ -15,96 +15,99 @@ class Printful_Admin_Status {
15
  const PF_CACHED_CHECKLIST = 'printful_cached_checklist';
16
 
17
  public static $_instance;
18
- public static $checklist_items = array(
19
- array(
20
- 'name' => 'Connection to Printful API',
21
- 'description' => 'Is your store successfully connected to Printful API?',
22
- 'method' => 'check_PF_API_connect',
23
- ),
24
- array(
25
- 'name' => 'Printful API key is set',
26
- 'description' => 'Your store needs access to Printful API to use most of it\'s features like shipping rates, tax rates and other settings.',
27
- 'method' => 'check_PF_API_key',
28
- ),
29
- array(
30
- 'name' => 'WordPress Permalinks',
31
- 'description' => 'WooCommerce API will not work unless your permalinks in Settings > Permalinks are set up correctly. Make sure you that they are NOT set to "plain".',
32
- 'method' => 'check_permalinks',
33
- ),
34
- array(
35
- 'name' => 'WordPress version',
36
- 'description' => 'WordPress should always be updated to the latest version. Updates can be installed from your WordPress admin dashboard.',
37
- 'method' => 'check_WP_version',
38
- ),
39
- array(
40
- 'name' => 'WooCommerce API enabled',
41
- 'description' => 'Your site needs to enbable WooCommerce API so that Printful can connect to it.',
42
- 'method' => 'check_WC_API_enabled',
43
- ),
44
- array(
45
- 'name' => 'WooCommerce Webhooks',
46
- 'description' => 'Printful requires WooCommerce webhooks to be set up to quickly capture you incoming orders, products updates etc.',
47
- 'method' => 'check_PF_webhooks',
48
- ),
49
- array(
50
- 'name' => 'WooCommerce API keys are set',
51
- 'description' => 'Printful needs access to your WooCommerce API for the integration to work - otherwise we can\'t sync your store, push or pull your products etc.',
52
- 'method' => 'check_WC_API_access',
53
- ),
54
- array(
55
- 'name' => 'WooCommerce authentication URL access',
56
- 'description' => 'Some hosts have unnecessarily intrusive security checks in place that prevent WooCommerce API authentication from working (mod_security rule #1234234). If this check fails, you will not be able authorize Printful app.',
57
- 'method' => 'check_WC_auth_url_access',
58
- ),
59
- array(
60
- 'name' => 'WordPress remote requests',
61
- 'description' => 'WordPress needs to be able to connect to Printful server to call webhooks. If this check fails, contact your hosting support.',
62
- 'method' => 'check_remote_requests',
63
- ),
64
- array(
65
- 'name' => 'Recent store sync errors',
66
- 'description' => 'Printful will connect to your store\'s API regularly and sync your latest products, orders etc. If there have been any recent issues with sync, this check will fail.',
67
- 'method' => 'check_PF_sync_errors',
68
- ),
69
- array(
70
- 'name' => 'Write permissions',
71
- 'description' => 'Make the uploads directory writable. This is required for mockup generator product push to work correctly. Contact your hosting provider if you need help with this.',
72
- 'method' => 'check_uploads_write',
73
- ),
74
- array(
75
- 'name' => 'PHP memory limit',
76
- 'description' => 'Set PHP allocated memory limit to at least 128mb. Contact your hosting provider if you need help with this.',
77
- 'method' => 'check_PHP_memory_limit',
78
- ),
79
- array(
80
- 'name' => 'PHP script time limit',
81
- 'description' => 'Set PHP script execution time limit to at least 30 seconds. This is required to successfully push products with many variants. Contact your hosting provider if you need help with this.',
82
- 'method' => 'check_PHP_time_limit',
83
- ),
84
- // array(
85
- // 'name' => 'Error logs',
86
- // 'description' => 'Your WordPress site needs to have it\'s error logging set up correctly so in case of issues you can figure out what\'s wrong. Note: your hosting might already have an independent log from WordPress.',
87
- // 'method' => 'check_WP_error_logs',
88
- // ),
89
- array(
90
- 'name' => 'W3 Total Cache DB Cache',
91
- 'description' => 'If you are using W3 Total Cache, the database caching feature needs to be disabled since it can cause issues with product push to store.',
92
- 'method' => 'check_W3_db_cache',
93
- 'silent' => true,
94
- ),
95
- array(
96
- 'name' => 'WP SpamShield',
97
- 'description' => 'If you are using WP SpamShield, you might experiance problems connecting to Printful and pushing products.',
98
- 'method' => 'check_wp_spamshield',
99
- 'silent' => true,
100
- ),
101
- array(
102
- 'name' => 'Remove Print Aura plugin',
103
- 'description' => 'Print Aura plugin is known to cause issues so it needs to be removed.',
104
- 'method' => 'check_printaura_plugin',
105
- 'silent' => true,
106
- ),
107
- );
 
 
 
108
 
109
  /**
110
  * @return Printful_Admin_Status
@@ -138,7 +141,7 @@ class Printful_Admin_Status {
138
  if ( $checklist ) {
139
  Printful_Admin::load_template( 'status-table', array( 'checklist' => $checklist ) );
140
  } else {
141
- Printful_Admin::load_template( 'ajax-loader', array( 'action' => 'get_printful_status_checklist', 'message' => 'Testing your store (this may take up to 30 seconds)...' ) );
142
  }
143
 
144
  Printful_Admin::load_template( 'footer' );
@@ -174,7 +177,7 @@ class Printful_Admin_Status {
174
  $list['overall_status'] = true;
175
  $issueCount = 0;
176
 
177
- foreach ( self::$checklist_items as $item ) {
178
  $list_item = array();
179
  $list_item['name'] = $item['name'];
180
  $list_item['description'] = $item['description'];
@@ -307,31 +310,32 @@ class Printful_Admin_Status {
307
  private function check_PF_webhooks() {
308
  global $wpdb;
309
 
310
- // Query args
311
- $args = array(
312
- 'post_type' => 'shop_webhook',
313
- 'nopaging' => true,
314
- 'ignore_sticky_posts' => true,
315
- 's' => self::PF_WEBHOOK_NAME,
316
- 'post_status' => 'published',
317
- );
318
-
319
- // Get the webhooks
320
- // In version 3.3 the webhooks are stored in separate table, before that they were stored in posts table
321
- if (version_compare(WC()->version, '3.3', '<')) {
322
- $webhook_results = new WP_Query($args);
323
- $webhooks = $webhook_results->posts;
324
- $count = count($webhooks) > 0;
325
- } else {
326
- $count = $wpdb->get_var(
327
- $wpdb->prepare("SELECT COUNT(*) as webhook_count FROM {$wpdb->prefix}wc_webhooks WHERE name = %s",
328
- self::PF_WEBHOOK_NAME
329
- ));
330
- }
 
331
 
332
- if ($count > 0) {
333
- return self::PF_STATUS_OK;
334
- }
335
 
336
  return self::PF_STATUS_FAIL;
337
  }
@@ -344,19 +348,24 @@ class Printful_Admin_Status {
344
  global $wpdb;
345
 
346
  //if any keys are set
347
- $query = "SELECT COUNT(*) as key_count FROM {$wpdb->prefix}woocommerce_api_keys";
348
- $count = $wpdb->get_var( $query );
 
349
 
350
  if ( $count == 0 ) {
351
  return self::PF_STATUS_FAIL;
352
  }
353
 
354
  // Get the API key with matching description
355
- $search = "AND description LIKE '%" . esc_sql( $wpdb->esc_like( wc_clean( self::API_KEY_SEARCH_STRING ) ) ) . "%' ";
356
- $query = "SELECT * FROM {$wpdb->prefix}woocommerce_api_keys WHERE 1 = 1 {$search} ORDER BY last_access DESC LIMIT 1";
357
- $key = $wpdb->get_row( $query );
358
-
359
-
 
 
 
 
360
 
361
  if ( ! empty( $key ) && $key->permissions == 'read_write' ) {
362
  return self::PF_STATUS_OK;
15
  const PF_CACHED_CHECKLIST = 'printful_cached_checklist';
16
 
17
  public static $_instance;
18
+
19
+ public static function getChecklistItems() {
20
+ return array(
21
+ array(
22
+ 'name' => __('Connection to Printful API', 'printful'),
23
+ 'description' => __('Is your store successfully connected to Printful API?', 'printful'),
24
+ 'method' => 'check_PF_API_connect',
25
+ ),
26
+ array(
27
+ 'name' => __('Printful API key is set', 'printful'),
28
+ 'description' => __('Your store needs access to Printful API to use most of it\'s features like shipping rates, tax rates and other settings.', 'printful'),
29
+ 'method' => 'check_PF_API_key',
30
+ ),
31
+ array(
32
+ 'name' => __('WordPress Permalinks', 'printful'),
33
+ 'description' => __('WooCommerce API will not work unless your permalinks in Settings > Permalinks are set up correctly. Make sure you that they are NOT set to "plain".', 'printful'),
34
+ 'method' => 'check_permalinks',
35
+ ),
36
+ array(
37
+ 'name' => __('WordPress version', 'printful'),
38
+ 'description' => __('WordPress should always be updated to the latest version. Updates can be installed from your WordPress admin dashboard.', 'printful'),
39
+ 'method' => 'check_WP_version',
40
+ ),
41
+ array(
42
+ 'name' => __('WooCommerce API enabled', 'printful'),
43
+ 'description' => __('Your site needs to enbable WooCommerce API so that Printful can connect to it.', 'printful'),
44
+ 'method' => 'check_WC_API_enabled',
45
+ ),
46
+ array(
47
+ 'name' => __('WooCommerce Webhooks', 'printful'),
48
+ 'description' => __('Printful requires WooCommerce webhooks to be set up to quickly capture you incoming orders, products updates etc.', 'printful'),
49
+ 'method' => 'check_PF_webhooks',
50
+ ),
51
+ array(
52
+ 'name' => __('WooCommerce API keys are set', 'printful'),
53
+ 'description' => __('Printful needs access to your WooCommerce API for the integration to work - otherwise we can\'t sync your store, push or pull your products etc.', 'printful'),
54
+ 'method' => 'check_WC_API_access',
55
+ ),
56
+ array(
57
+ 'name' => __('WooCommerce authentication URL access', 'printful'),
58
+ 'description' => __('Some hosts have unnecessarily intrusive security checks in place that prevent WooCommerce API authentication from working (mod_security rule #1234234). If this check fails, you will not be able authorize Printful app.', 'printful'),
59
+ 'method' => 'check_WC_auth_url_access',
60
+ ),
61
+ array(
62
+ 'name' => __('WordPress remote requests', 'printful'),
63
+ 'description' => __('WordPress needs to be able to connect to Printful server to call webhooks. If this check fails, contact your hosting support.', 'printful'),
64
+ 'method' => 'check_remote_requests',
65
+ ),
66
+ array(
67
+ 'name' => __('Recent store sync errors', 'printful'),
68
+ 'description' => __('Printful will connect to your store\'s API regularly and sync your latest products, orders etc. If there have been any recent issues with sync, this check will fail.', 'printful'),
69
+ 'method' => 'check_PF_sync_errors',
70
+ ),
71
+ array(
72
+ 'name' => __('Write permissions', 'printful'),
73
+ 'description' => __('Make the uploads directory writable. This is required for mockup generator product push to work correctly. Contact your hosting provider if you need help with this.', 'printful'),
74
+ 'method' => 'check_uploads_write',
75
+ ),
76
+ array(
77
+ 'name' => __('PHP memory limit', 'printful'),
78
+ 'description' => __('Set PHP allocated memory limit to at least 128mb. Contact your hosting provider if you need help with this.', 'printful'),
79
+ 'method' => 'check_PHP_memory_limit',
80
+ ),
81
+ array(
82
+ 'name' => __('PHP script time limit', 'printful'),
83
+ 'description' => __('Set PHP script execution time limit to at least 30 seconds. This is required to successfully push products with many variants. Contact your hosting provider if you need help with this.', 'printful'),
84
+ 'method' => 'check_PHP_time_limit',
85
+ ),
86
+ // array(
87
+ // 'name' => __('Error logs', 'printful'),
88
+ // 'description' => __('Your WordPress site needs to have it\'s error logging set up correctly so in case of issues you can figure out what\'s wrong. Note: your hosting might already have an independent log from WordPress.', 'printful'),
89
+ // 'method' => 'check_WP_error_logs',
90
+ // ),
91
+ array(
92
+ 'name' => __('W3 Total Cache DB Cache', 'printful'),
93
+ 'description' => __('If you are using W3 Total Cache, the database caching feature needs to be disabled since it can cause issues with product push to store.', 'printful'),
94
+ 'method' => 'check_W3_db_cache',
95
+ 'silent' => true,
96
+ ),
97
+ array(
98
+ 'name' => __('WP SpamShield', 'printful'),
99
+ 'description' => __('If you are using WP SpamShield, you might experiance problems connecting to Printful and pushing products.', 'printful'),
100
+ 'method' => 'check_wp_spamshield',
101
+ 'silent' => true,
102
+ ),
103
+ array(
104
+ 'name' => __('Remove Print Aura plugin', 'printful'),
105
+ 'description' => __('Print Aura plugin is known to cause issues so it needs to be removed.', 'printful'),
106
+ 'method' => 'check_printaura_plugin',
107
+ 'silent' => true,
108
+ ),
109
+ );
110
+ }
111
 
112
  /**
113
  * @return Printful_Admin_Status
141
  if ( $checklist ) {
142
  Printful_Admin::load_template( 'status-table', array( 'checklist' => $checklist ) );
143
  } else {
144
+ Printful_Admin::load_template( 'ajax-loader', array( 'action' => 'get_printful_status_checklist', 'message' => __( 'Testing your store (this may take up to 30 seconds)...', 'printful' ) ) );
145
  }
146
 
147
  Printful_Admin::load_template( 'footer' );
177
  $list['overall_status'] = true;
178
  $issueCount = 0;
179
 
180
+ foreach ( self::getChecklistItems() as $item ) {
181
  $list_item = array();
182
  $list_item['name'] = $item['name'];
183
  $list_item['description'] = $item['description'];
310
  private function check_PF_webhooks() {
311
  global $wpdb;
312
 
313
+ // Get the webhooks
314
+ // In version 3.3 the webhooks are stored in separate table, before that they were stored in posts table
315
+ if ( version_compare( WC()->version, '3.3', '<' ) ) {
316
+
317
+ // Query args
318
+ $args = array(
319
+ 'post_type' => 'shop_webhook',
320
+ 'nopaging' => true,
321
+ 'ignore_sticky_posts' => true,
322
+ 's' => self::PF_WEBHOOK_NAME,
323
+ 'post_status' => 'published',
324
+ );
325
+
326
+ $webhook_results = new WP_Query( $args );
327
+ $webhooks = $webhook_results->posts;
328
+ $count = count( $webhooks ) > 0;
329
+ } else {
330
+ $count = $wpdb->get_var(
331
+ $wpdb->prepare( "SELECT COUNT(*) as webhook_count FROM {$wpdb->prefix}wc_webhooks WHERE name = %s",
332
+ self::PF_WEBHOOK_NAME
333
+ ) );
334
+ }
335
 
336
+ if ( $count > 0 ) {
337
+ return self::PF_STATUS_OK;
338
+ }
339
 
340
  return self::PF_STATUS_FAIL;
341
  }
348
  global $wpdb;
349
 
350
  //if any keys are set
351
+ $count = $wpdb->get_var(
352
+ "SELECT COUNT(*) as key_count FROM {$wpdb->prefix}woocommerce_api_keys"
353
+ );
354
 
355
  if ( $count == 0 ) {
356
  return self::PF_STATUS_FAIL;
357
  }
358
 
359
  // Get the API key with matching description
360
+ $printfulKey = esc_sql( $wpdb->esc_like( wc_clean( self::API_KEY_SEARCH_STRING ) ) );
361
+ $queryArg = '%'. $wpdb->esc_like( $printfulKey ) . '%';
362
+
363
+ $key = $wpdb->get_row(
364
+ $wpdb->prepare(
365
+ "SELECT * FROM {$wpdb->prefix}woocommerce_api_keys WHERE description LIKE %s ORDER BY last_access LIMIT 1",
366
+ $queryArg
367
+ )
368
+ );
369
 
370
  if ( ! empty( $key ) && $key->permissions == 'read_write' ) {
371
  return self::PF_STATUS_OK;
includes/class-printful-admin-support.php CHANGED
@@ -33,7 +33,7 @@ class Printful_Admin_Support {
33
 
34
  Printful_Admin::load_template( 'header', array( 'tabs' => Printful_Admin::get_tabs() ) );
35
 
36
- Printful_Admin::load_template( 'ajax-loader', array( 'action' => 'get_printful_status_report', 'message' => 'Building support report (this may take up to 30 seconds)...' ) );
37
 
38
  Printful_Admin::load_template( 'support-info' );
39
 
@@ -65,7 +65,7 @@ class Printful_Admin_Support {
65
 
66
  ob_start();
67
 
68
- echo "##### Printful Checklist #####\n";
69
  $checklist = Printful_Admin_Status::get_checklist();
70
  foreach ( $checklist['items'] as $item ) {
71
  $status = 'OK';
@@ -75,22 +75,22 @@ class Printful_Admin_Support {
75
  $status = 'FAIL';
76
  }
77
  echo "* ";
78
- echo str_pad( esc_html($item['name']), 30 ) . "=> " . esc_html($status) . "\n";
79
  }
80
 
81
  echo "\n\n##### Printful Last Sync's #####\n";
82
  $syncReport = $this->get_sync_report();
83
  if ( ! empty( $syncReport ) ) {
84
- echo str_pad( 'Date', 30 );
85
- echo str_pad( 'Request', 30 );
86
- echo str_pad( 'Message', 30 );
87
  echo "\n";
88
 
89
  foreach ( $syncReport as $sr ) {
90
  echo "* ";
91
- echo str_pad( esc_html($sr['date']) . ';', 30 );
92
- echo str_pad( esc_html($sr['path']) . ';', 30 );
93
- echo str_pad( esc_html($sr['message']) . ';', 30 );
94
  echo "\n";
95
  }
96
  }
@@ -105,7 +105,7 @@ class Printful_Admin_Support {
105
  foreach ( $system_status->get_active_plugins() as $plugin ) {
106
  if ( ! empty( $plugin['name'] ) ) {
107
  echo "* ";
108
- echo esc_html( $plugin['name'] ) . " (" . $plugin['version'] . ")\n";
109
  }
110
  }
111
 
@@ -203,7 +203,7 @@ class Printful_Admin_Support {
203
  foreach ( $data as $key => $item ) {
204
  if ( is_string( $item ) ) {
205
  echo "* ";
206
- echo str_pad( $key, 30 ) . "=> " . $item . "\n";
207
  }
208
  }
209
  }
33
 
34
  Printful_Admin::load_template( 'header', array( 'tabs' => Printful_Admin::get_tabs() ) );
35
 
36
+ Printful_Admin::load_template( 'ajax-loader', array( 'action' => 'get_printful_status_report', 'message' => __( 'Building support report (this may take up to 30 seconds)...', 'printful' ) ) );
37
 
38
  Printful_Admin::load_template( 'support-info' );
39
 
65
 
66
  ob_start();
67
 
68
+ echo __( "##### Printful Checklist #####\n", 'printful' );
69
  $checklist = Printful_Admin_Status::get_checklist();
70
  foreach ( $checklist['items'] as $item ) {
71
  $status = 'OK';
75
  $status = 'FAIL';
76
  }
77
  echo "* ";
78
+ echo esc_html( str_pad( esc_html( $item['name'] ), 30 ) ) . '=> ' . esc_html( $status ) . "\n";
79
  }
80
 
81
  echo "\n\n##### Printful Last Sync's #####\n";
82
  $syncReport = $this->get_sync_report();
83
  if ( ! empty( $syncReport ) ) {
84
+ echo esc_html( str_pad( 'Date', 30 ) );
85
+ echo esc_html( str_pad( 'Request', 30 ) );
86
+ echo esc_html( str_pad( 'Message', 30 ) );
87
  echo "\n";
88
 
89
  foreach ( $syncReport as $sr ) {
90
  echo "* ";
91
+ echo esc_html( str_pad( $sr['date'] . ';', 30 ) );
92
+ echo esc_html( str_pad( $sr['path'] . ';', 30 ) );
93
+ echo esc_html( str_pad( $sr['message'] . ';', 30 ) );
94
  echo "\n";
95
  }
96
  }
105
  foreach ( $system_status->get_active_plugins() as $plugin ) {
106
  if ( ! empty( $plugin['name'] ) ) {
107
  echo "* ";
108
+ echo esc_html( $plugin['name'] ) . " (" . esc_html( $plugin['version'] ) . ")\n";
109
  }
110
  }
111
 
203
  foreach ( $data as $key => $item ) {
204
  if ( is_string( $item ) ) {
205
  echo "* ";
206
+ echo esc_html( str_pad($key, 30) ) . "=> " . esc_html($item) . "\n";
207
  }
208
  }
209
  }
includes/class-printful-admin.php CHANGED
@@ -68,7 +68,7 @@ class Printful_Admin {
68
  public function register_admin_menu_page() {
69
 
70
  add_menu_page(
71
- self::PAGE_TITLE_DASHBOARD,
72
  self::MENU_TITLE_TOP,
73
  self::CAPABILITY,
74
  self::MENU_SLUG_DASHBOARD,
@@ -103,15 +103,15 @@ class Printful_Admin {
103
  public static function get_tabs() {
104
 
105
  $tabs = array(
106
- array( 'name' => 'Settings', 'tab_url' => 'settings' ),
107
- array( 'name' => 'Status', 'tab_url' => 'status' ),
108
- array( 'name' => 'Support', 'tab_url' => 'support' ),
109
  );
110
 
111
  if ( Printful_Integration::instance()->is_connected() ) {
112
- array_unshift( $tabs, array( 'name' => 'Dashboard', 'tab_url' => false ) );
113
  } else {
114
- array_unshift( $tabs, array( 'name' => 'Connect', 'tab_url' => false ) );
115
  }
116
 
117
  return $tabs;
68
  public function register_admin_menu_page() {
69
 
70
  add_menu_page(
71
+ __('Dashboard', 'printful'),
72
  self::MENU_TITLE_TOP,
73
  self::CAPABILITY,
74
  self::MENU_SLUG_DASHBOARD,
103
  public static function get_tabs() {
104
 
105
  $tabs = array(
106
+ array( 'name' => __( 'Settings', 'printful' ), 'tab_url' => 'settings' ),
107
+ array( 'name' => __( 'Status', 'printful' ), 'tab_url' => 'status' ),
108
+ array( 'name' => __( 'Support', 'printful' ), 'tab_url' => 'support' ),
109
  );
110
 
111
  if ( Printful_Integration::instance()->is_connected() ) {
112
+ array_unshift( $tabs, array( 'name' => __( 'Dashboard', 'printful' ), 'tab_url' => false ) );
113
  } else {
114
+ array_unshift( $tabs, array( 'name' => __( 'Connect', 'printful' ), 'tab_url' => false ) );
115
  }
116
 
117
  return $tabs;
includes/class-printful-carriers.php CHANGED
@@ -41,7 +41,7 @@ class Printful_Carriers {
41
  public function refresh_carriers() {
42
 
43
  try {
44
- $carriers = Printful_Integration::instance()->get_client()->get( 'store/carriers-services' );
45
  $this->update_carrier_cache( $carriers );
46
  } catch (PrintfulApiException $e) {
47
  $carriers = array();
@@ -74,7 +74,7 @@ class Printful_Carriers {
74
 
75
  $shipping = new self;
76
  try {
77
- $carriers = Printful_Integration::instance()->get_client()->post( 'store/carriers-services', $data );
78
  $shipping->update_carrier_cache( $carriers );
79
  } catch ( PrintfulApiException $e ) {
80
  $carriers = false;
41
  public function refresh_carriers() {
42
 
43
  try {
44
+ $carriers = Printful_Integration::instance()->get_client()->get( 'store/carriers-services' );
45
  $this->update_carrier_cache( $carriers );
46
  } catch (PrintfulApiException $e) {
47
  $carriers = array();
74
 
75
  $shipping = new self;
76
  try {
77
+ $carriers = Printful_Integration::instance()->get_client()->post( 'store/carriers-services', $data );
78
  $shipping->update_carrier_cache( $carriers );
79
  } catch ( PrintfulApiException $e ) {
80
  $carriers = false;
includes/class-printful-integration.php CHANGED
@@ -76,18 +76,18 @@ class Printful_Integration
76
  $this->clear_connect_error();
77
  set_transient( self::PF_API_CONNECT_STATUS, array( 'status' => 1 ) ); //no expiry
78
  } elseif ( $storeData['type'] != 'woocommerce' ) {
79
- $message = 'Invalid API key. This API key belongs to a ' . ucfirst( $storeData['type'] ) . ' store. WooCommerce store must used to connect with Printful. Enter the correct key in <a href="%s">Settings</a>.';
80
  $settings_url = admin_url( 'admin.php?page=printful-dashboard&tab=settings' );
81
- $printful_url = Printful_Base::get_printful_host() . 'dashboard/';
82
  $this->set_connect_error( sprintf( $message, $settings_url, $printful_url ) );
83
  set_transient( self::PF_API_CONNECT_STATUS, array( 'status' => 0 ), MINUTE_IN_SECONDS ); //try again in 1 minute
84
  }
85
  } catch ( Exception $e ) {
86
 
87
  if ( $e->getCode() == 401 ) {
88
- $message = 'Invalid API key. Please ensure that your API key in <a href="%s">Settings</a> matches the one in your <a href="%s">Printful dashboard</a>.';
89
  $settings_url = admin_url( 'admin.php?page=printful-dashboard&tab=settings' );
90
- $printful_url = Printful_Base::get_printful_host() . 'dashboard/';
91
  $this->set_connect_error( sprintf( $message, $settings_url, $printful_url ) );
92
  set_transient( self::PF_API_CONNECT_STATUS, array( 'status' => 0 ), MINUTE_IN_SECONDS ); //try again in 1 minute
93
  } else {
76
  $this->clear_connect_error();
77
  set_transient( self::PF_API_CONNECT_STATUS, array( 'status' => 1 ) ); //no expiry
78
  } elseif ( $storeData['type'] != 'woocommerce' ) {
79
+ $message = 'Invalid API key. This API key belongs to a ' . ucfirst( $storeData['type'] ) . ' store. Please copy the correct key from <a href="%s">Printful store settings</a> and enter it in the <a href="%s">Printful plugin settings</a>';
80
  $settings_url = admin_url( 'admin.php?page=printful-dashboard&tab=settings' );
81
+ $printful_url = Printful_Base::get_printful_host() . 'dashboard/store';
82
  $this->set_connect_error( sprintf( $message, $settings_url, $printful_url ) );
83
  set_transient( self::PF_API_CONNECT_STATUS, array( 'status' => 0 ), MINUTE_IN_SECONDS ); //try again in 1 minute
84
  }
85
  } catch ( Exception $e ) {
86
 
87
  if ( $e->getCode() == 401 ) {
88
+ $message = 'Invalid API key. Please ensure that your API key in <a href="%s">Printful plugin settings</a> matches the one in your <a href="%s">Printful store settings</a>.';
89
  $settings_url = admin_url( 'admin.php?page=printful-dashboard&tab=settings' );
90
+ $printful_url = Printful_Base::get_printful_host() . 'dashboard/store';
91
  $this->set_connect_error( sprintf( $message, $settings_url, $printful_url ) );
92
  set_transient( self::PF_API_CONNECT_STATUS, array( 'status' => 0 ), MINUTE_IN_SECONDS ); //try again in 1 minute
93
  } else {
includes/class-printful-rest-api.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * API class
5
+ */
6
+ class Printful_REST_API
7
+ {
8
+ /**
9
+ * Register the REST API routes.
10
+ */
11
+ public static function init() {
12
+ register_rest_route('wc/v2', '/printful/access', array(
13
+ array(
14
+ 'methods' => WP_REST_Server::EDITABLE,
15
+ 'callback' => array( 'Printful_REST_API', 'set_printful_access' ),
16
+ 'args' => array(
17
+ 'accessKey' => array(
18
+ 'required' => false,
19
+ 'type' => 'string',
20
+ 'description' => __( 'Printful access key', 'printful' ),
21
+ ),
22
+ 'storeId' => array(
23
+ 'required' => false,
24
+ 'type' => 'integer',
25
+ 'description' => __( 'Store Identifier', 'printful' ),
26
+ ),
27
+ ),
28
+ )
29
+ ) );
30
+
31
+ register_rest_route('wc/v2', '/printful/products/(?P<product_id>\d+)/size-chart', array(
32
+ array(
33
+ 'methods' => WP_REST_Server::EDITABLE,
34
+ 'callback' => array( 'Printful_REST_API', 'post_size_guide' ),
35
+ 'args' => array(
36
+ 'product_id' => array(
37
+ 'description' => __( 'Unique identifier for the resource.', 'printful' ),
38
+ 'type' => 'integer',
39
+ ),
40
+ 'size_chart' => array(
41
+ 'required' => true,
42
+ 'type' => 'string',
43
+ 'description' => __( 'Printful size guide', 'printful' ),
44
+ )
45
+ )
46
+ )
47
+ ) );
48
+
49
+ register_rest_route('wc/v2', '/printful/version', array(
50
+ array(
51
+ 'methods' => WP_REST_Server::READABLE,
52
+ 'callback' => array( 'Printful_REST_API', 'get_version' ),
53
+ )
54
+ ) );
55
+
56
+ register_rest_route('wc/v2', '/printful/store_data', array(
57
+ array(
58
+ 'methods' => WP_REST_Server::READABLE,
59
+ 'callback' => array( 'Printful_REST_API', 'get_store_data' ),
60
+ )
61
+ ) );
62
+ }
63
+
64
+ /**
65
+ * @param WP_REST_Request $request
66
+ * @return array
67
+ */
68
+ public static function set_printful_access( $request )
69
+ {
70
+ $error = false;
71
+
72
+ $api_key = $request->get_param('accessKey');
73
+ $store_id = $request->get_param('storeId');
74
+
75
+ $option = Printful_Integration::instance()->get_option( 'printful_settings', array() );
76
+ $store_id = intval( $store_id );
77
+
78
+ if ( ! is_string( $api_key ) || strlen( $api_key ) == 0 || $store_id == 0 ) {
79
+ $error = 'Failed to update access data';
80
+ }
81
+
82
+ $option['printful_key'] = $api_key;
83
+ $option['printful_store_id'] = $store_id;
84
+
85
+ Printful_Integration::instance()->update_settings( $option );
86
+
87
+ return array(
88
+ 'error' => $error,
89
+ );
90
+ }
91
+
92
+ /**
93
+ * Submit size guide
94
+ * @param array $data
95
+ * @return array|WP_Error
96
+ */
97
+ public static function post_size_guide( $data )
98
+ {
99
+ if ( empty( $data['size_chart'] ) ) {
100
+ return new WP_Error( 'printful_api_size_chart_empty', __( 'No size chart was provided', 'printful' ), ['status' => 400]);
101
+ }
102
+
103
+ //product id is valid
104
+ $product_id = intval( $data['product_id'] );
105
+ if ( $product_id < 1 ) {
106
+ return new WP_Error( 'printful_api_product_not_found', __( 'The product ID is invalid', 'printful' ), ['status' => 400]);
107
+ }
108
+
109
+ //product exists
110
+ $product = get_post( $product_id );
111
+ if ( empty( $product ) || $product->post_type != 'product' ) {
112
+ return new WP_Error( 'printful_api_product_not_found', __( 'The product is not found', 'printful' ), ['status' => 400]);
113
+ }
114
+
115
+ //how about permissions?
116
+ $post_type = get_post_type_object( $product->post_type );
117
+ if ( ! current_user_can( $post_type->cap->edit_post, $product->ID ) ) {
118
+ return new WP_Error( 'printful_api_user_cannot_edit_product_size_chart', __( 'You do not have permission to edit the size chart', 'printful' ), ['status' => 401]);
119
+ }
120
+
121
+ //lets do this
122
+ update_post_meta( $product_id, 'pf_size_chart', htmlspecialchars( $data['size_chart'] ) );
123
+
124
+ return array(
125
+ 'product' => $product,
126
+ 'size_chart' => $data['size_chart'],
127
+ );
128
+ }
129
+
130
+ /**
131
+ * Allow remotely get plugin version for debug purposes
132
+ */
133
+ public static function get_version() {
134
+
135
+ $error = false;
136
+
137
+ try {
138
+ $client = Printful_Integration::instance()->get_client();
139
+ $store_data = $client->get( 'store' );
140
+ } catch ( Exception $exception ) {
141
+ $error = $exception->getMessage();
142
+ }
143
+
144
+ $checklist = Printful_Admin_Status::get_checklist();
145
+ $checklist['overall_status'] = ( $checklist['overall_status'] ? 'OK' : 'FAIL' );
146
+
147
+ foreach ( $checklist['items'] as $checklist_key => $checklist_item ) {
148
+
149
+ if ( $checklist_item['status'] == Printful_Admin_Status::PF_STATUS_OK ) {
150
+ $checklist_item['status'] = 'OK';
151
+ } elseif ( $checklist_item['status'] == Printful_Admin_Status::PF_STATUS_WARNING ) {
152
+ $checklist_item['status'] = 'WARNING';
153
+ } else {
154
+ $checklist_item['status'] = 'FAIL';
155
+ }
156
+
157
+ $checklist['items'][ $checklist_key ] = $checklist_item;
158
+ }
159
+
160
+ return array(
161
+ 'version' => Printful_Base::VERSION,
162
+ 'api_key' => Printful_Integration::instance()->get_option('printful_key'),
163
+ 'store_id' => ! empty( $store_data['id'] ) ? $store_data['id'] : false,
164
+ 'error' => $error,
165
+ 'status_checklist' => $checklist,
166
+ );
167
+ }
168
+
169
+ /**
170
+ * Get necessary store data
171
+ * @return array
172
+ */
173
+ public static function get_store_data() {
174
+ return array(
175
+ 'website' => get_site_url(),
176
+ 'version' => WC()->version,
177
+ 'name' => get_bloginfo( 'title', 'display' )
178
+ );
179
+ }
180
+ }
includes/class-printful-shipping.php CHANGED
@@ -8,6 +8,8 @@ class Printful_Shipping extends WC_Shipping_Method
8
  public $override_defaults = true;
9
  private $last_error = false;
10
 
 
 
11
  //Store whether currently processed package contains Printful products (for WC<2.6)
12
  private $printful_package = true;
13
 
@@ -52,15 +54,15 @@ class Printful_Shipping extends WC_Shipping_Method
52
  'default' => 'no',
53
  ),
54
  'override_defaults' => array(
55
- 'title' => 'Disable Woocommerce rates',
56
  'type' => 'checkbox',
57
- 'label' => 'Disable standard Woocommerce rates for products fulfilled by Printful',
58
  'default' => 'yes',
59
  ),
60
  'show_warnings' => array(
61
- 'title' => 'Show Printful warnings',
62
  'type' => 'checkbox',
63
- 'label' => 'Display Printful status messages if rate API request fails',
64
  'default' => 'yes',
65
  ),
66
  );
@@ -279,12 +281,20 @@ class Printful_Shipping extends WC_Shipping_Method
279
 
280
  foreach ( $response as $rate ) {
281
  $rateData = array(
282
- 'id' => $this->id . '_' . $rate['id'],
283
  'label' => $rate['name'],
284
  'cost' => $rate['rate'],
285
  'calc_tax' => 'per_order',
286
  );
 
 
 
 
 
 
287
  $this->add_rate( $rateData );
 
 
288
  }
289
  } catch ( PrintfulException $e ) {
290
  $this->set_error( $e );
8
  public $override_defaults = true;
9
  private $last_error = false;
10
 
11
+ const PRINTFUL_SHIPPING = 'printful_shipping';
12
+
13
  //Store whether currently processed package contains Printful products (for WC<2.6)
14
  private $printful_package = true;
15
 
54
  'default' => 'no',
55
  ),
56
  'override_defaults' => array(
57
+ 'title' => __( 'Disable Woocommerce rates', 'woocommerce' ),
58
  'type' => 'checkbox',
59
+ 'label' => __( 'Disable standard Woocommerce rates for products fulfilled by Printful', 'woocommerce' ),
60
  'default' => 'yes',
61
  ),
62
  'show_warnings' => array(
63
+ 'title' => __( 'Show Printful warnings', 'woocommerce' ),
64
  'type' => 'checkbox',
65
+ 'label' => __( 'Display Printful status messages if rate API request fails', 'woocommerce' ),
66
  'default' => 'yes',
67
  ),
68
  );
281
 
282
  foreach ( $response as $rate ) {
283
  $rateData = array(
284
+ 'id' => $this->id . '_' . $rate['id'],
285
  'label' => $rate['name'],
286
  'cost' => $rate['rate'],
287
  'calc_tax' => 'per_order',
288
  );
289
+
290
+ // Before 3.4.0 rate could be passed as ID, after it's set as method_id which refers to class ID
291
+ if ( version_compare( WC()->version, '3.4.0', '>=' ) ) {
292
+ $this->id = self::PRINTFUL_SHIPPING . '_' . $rate['id'];
293
+ }
294
+
295
  $this->add_rate( $rateData );
296
+ // Reset class ID after adding rate so ID name does not stack as huge string in foreach
297
+ $this->id = self::PRINTFUL_SHIPPING;
298
  }
299
  } catch ( PrintfulException $e ) {
300
  $this->set_error( $e );
includes/class-printful-size-chart-tab.php CHANGED
@@ -50,7 +50,7 @@ class Printful_Size_Chart_Tab {
50
  */
51
  public function size_chart_tab_content() {
52
 
53
- echo '<h2>' . __( 'Size Chart', 'printful' ) . '</h2>';
54
  echo $this->get_size_chart_content();
55
  }
56
 
50
  */
51
  public function size_chart_tab_content() {
52
 
53
+ echo '<h2>' . esc_html__( 'Size Chart', 'printful' ) . '</h2>';
54
  echo $this->get_size_chart_content();
55
  }
56
 
includes/templates/connect.php CHANGED
@@ -2,19 +2,19 @@
2
 
3
  <div class="printful-connect-inner">
4
 
5
- <h1>Connect to Printful</h1>
6
 
7
  <img src=" <?php echo esc_url(Printful_Base::get_asset_url() . 'images/connect.svg'); ?>" class="connect-image" alt="connect to printful">
8
 
9
  <?php
10
  if ( ! empty( $issues ) ) {
11
  ?>
12
- <p>To connect your store to Printful, fix the following errors:</p>
13
  <div class="printful-notice">
14
  <ul>
15
  <?php
16
  foreach ( $issues as $issue ) {
17
- echo '<li>' . $issue . '</li>';
18
  }
19
  ?>
20
  </ul>
@@ -22,18 +22,18 @@
22
  <?php
23
  $url = '#';
24
  } else {
25
- ?><p class="connect-description">You're almost done! Just 2 more steps to have your WooCommerce store connected to Printful for automatic order fulfillment.</p><?php
26
  $url = Printful_Base::get_printful_host() . 'dashboard/woocommerce/plugin-connect?website=' . urlencode( trailingslashit( get_home_url() ) ) . '&key=' . urlencode( $consumer_key ) . '&returnUrl=' . urlencode( get_admin_url( null,'admin.php?page=' . Printful_Admin::MENU_SLUG_DASHBOARD ) );
27
  }
28
 
29
- echo '<a href="' . esc_url($url) . '" class="button button-primary printful-connect-button ' . ( ! empty( $issues ) ? 'disabled' : '' ) . '" target="_blank">Connect</a>';
30
  ?>
31
 
32
  <img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ) ?>" class="loader hidden" width="20px" height="20px" alt="loader"/>
33
 
34
  <script type="text/javascript">
35
  jQuery(document).ready(function () {
36
- Printful_Connect.init('<?php echo admin_url( 'admin-ajax.php?action=ajax_force_check_connect_status' ); ?>');
37
  });
38
  </script>
39
  </div>
2
 
3
  <div class="printful-connect-inner">
4
 
5
+ <h1><?php esc_html_e('Connect to Printful', 'printful'); ?></h1>
6
 
7
  <img src=" <?php echo esc_url(Printful_Base::get_asset_url() . 'images/connect.svg'); ?>" class="connect-image" alt="connect to printful">
8
 
9
  <?php
10
  if ( ! empty( $issues ) ) {
11
  ?>
12
+ <p><?php esc_html_e('To connect your store to Printful, fix the following errors:', 'printful'); ?></p>
13
  <div class="printful-notice">
14
  <ul>
15
  <?php
16
  foreach ( $issues as $issue ) {
17
+ echo '<li>' . esc_html( $issue ) . '</li>';
18
  }
19
  ?>
20
  </ul>
22
  <?php
23
  $url = '#';
24
  } else {
25
+ ?><p class="connect-description"><?php esc_html_e('You\'re almost done! Just 2 more steps to have your WooCommerce store connected to Printful for automatic order fulfillment.', 'printful'); ?></p><?php
26
  $url = Printful_Base::get_printful_host() . 'dashboard/woocommerce/plugin-connect?website=' . urlencode( trailingslashit( get_home_url() ) ) . '&key=' . urlencode( $consumer_key ) . '&returnUrl=' . urlencode( get_admin_url( null,'admin.php?page=' . Printful_Admin::MENU_SLUG_DASHBOARD ) );
27
  }
28
 
29
+ echo '<a href="' . esc_url($url) . '" class="button button-primary printful-connect-button ' . ( ! empty( $issues ) ? 'disabled' : '' ) . '" target="_blank">' . esc_html__('Connect', 'printful') . '</a>';
30
  ?>
31
 
32
  <img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ) ?>" class="loader hidden" width="20px" height="20px" alt="loader"/>
33
 
34
  <script type="text/javascript">
35
  jQuery(document).ready(function () {
36
+ Printful_Connect.init('<?php echo esc_url( admin_url( 'admin-ajax.php?action=ajax_force_check_connect_status' ) ); ?>');
37
  });
38
  </script>
39
  </div>
includes/templates/error.php CHANGED
@@ -1 +1 @@
1
- <p class="printful-error"><b>Error:</b> <?php echo wp_kses_post($error); ?></p>
1
+ <p class="printful-error"><b><?php esc_html_e('Error:', 'printful'); ?></b> <?php echo wp_kses_post($error); ?></p>
includes/templates/inline-script.php CHANGED
@@ -1,3 +1,3 @@
1
  <script type="text/javascript">
2
- <?php echo $script; ?>
3
  </script>
1
  <script type="text/javascript">
2
+ <?php echo esc_js( $script ); ?>
3
  </script>
includes/templates/order-table.php CHANGED
@@ -6,12 +6,12 @@
6
  <table class="wp-list-table widefat fixed striped printful-latest-orders">
7
  <thead>
8
  <tr>
9
- <th class="col-order">Order</th>
10
- <th class="col-date">Date</th>
11
- <th class="col-from">From</th>
12
- <th class="col-status">Status</th>
13
- <th class="col-total">Total</th>
14
- <th class="col-actions">Actions</th>
15
  </tr>
16
  </thead>
17
  <tbody>
@@ -22,7 +22,7 @@
22
  <td>
23
  <?php
24
  if ( $order['external_id'] ) {
25
- echo '<a href="' . get_edit_post_link( $order['external_id'] ) . '">';
26
  echo '#' . esc_html( $order['external_id'] );
27
  echo '</a>';
28
  } else {
@@ -43,7 +43,7 @@
43
  $<?php echo esc_html( $order['costs']['total'] ); ?>
44
  </td>
45
  <td>
46
- <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard?order_id=<?php echo esc_attr($order['id']); ?>" target="_blank">Open in Printful</a>
47
  </td>
48
  </tr>
49
 
@@ -52,18 +52,18 @@
52
  </tbody>
53
  <tfoot>
54
  <tr>
55
- <th class="col-order">Order</th>
56
- <th class="col-date">Date</th>
57
- <th class="col-from">From</th>
58
- <th class="col-status">Status</th>
59
- <th class="col-total">Total</th>
60
- <th class="col-actions">Actions</th>
61
  </tr>
62
  </tfoot>
63
  </table>
64
 
65
  <?php else: ?>
66
  <div class="printful-latest-orders">
67
- <p>Once your store gets some Printful product orders, they will be shown here!</p>
68
  </div>
69
  <?php endif; ?>
6
  <table class="wp-list-table widefat fixed striped printful-latest-orders">
7
  <thead>
8
  <tr>
9
+ <th class="col-order"><?php esc_html_e('Order', 'printful'); ?></th>
10
+ <th class="col-date"><?php esc_html_e('Date', 'printful'); ?></th>
11
+ <th class="col-from"><?php esc_html_e('From', 'printful'); ?></th>
12
+ <th class="col-status"><?php esc_html_e('Status', 'printful'); ?></th>
13
+ <th class="col-total"><?php esc_html_e('Total', 'printful'); ?></th>
14
+ <th class="col-actions"><?php esc_html_e('Actions', 'printful'); ?></th>
15
  </tr>
16
  </thead>
17
  <tbody>
22
  <td>
23
  <?php
24
  if ( $order['external_id'] ) {
25
+ echo '<a href="' . esc_url( get_edit_post_link( $order['external_id'] ) ) . '">';
26
  echo '#' . esc_html( $order['external_id'] );
27
  echo '</a>';
28
  } else {
43
  $<?php echo esc_html( $order['costs']['total'] ); ?>
44
  </td>
45
  <td>
46
+ <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard?order_id=<?php echo esc_attr($order['id']); ?>" target="_blank"><?php esc_html_e('Open in Printful', 'printful'); ?></a>
47
  </td>
48
  </tr>
49
 
52
  </tbody>
53
  <tfoot>
54
  <tr>
55
+ <th class="col-order"><?php esc_html_e('Order', 'printful'); ?></th>
56
+ <th class="col-date"><?php esc_html_e('Date', 'printful'); ?></th>
57
+ <th class="col-from"><?php esc_html_e('From', 'printful'); ?></th>
58
+ <th class="col-status"><?php esc_html_e('Status', 'printful'); ?></th>
59
+ <th class="col-total"><?php esc_html_e('Total', 'printful'); ?></th>
60
+ <th class="col-actions"><?php esc_html_e('Actions', 'printful'); ?></th>
61
  </tr>
62
  </tfoot>
63
  </table>
64
 
65
  <?php else: ?>
66
  <div class="printful-latest-orders">
67
+ <p><?php esc_html_e('Once your store gets some Printful product orders, they will be shown here!', 'printful'); ?></p>
68
  </div>
69
  <?php endif; ?>
includes/templates/quick-links.php CHANGED
@@ -3,30 +3,30 @@
3
  <div class="printful-quick-links">
4
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard" target="_blank" class="printful-quick-links-item">
5
  <span class="dashicons dashicons-cart"></span>
6
- <h4>Orders</h4>
7
  </a>
8
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/library" target="_blank" class="printful-quick-links-item">
9
  <span class="dashicons dashicons-images-alt"></span>
10
- <h4>File library</h4>
11
  </a>
12
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/store" target="_blank" class="printful-quick-links-item">
13
  <span class="dashicons dashicons-store"></span>
14
- <h4>Stores</h4>
15
  </a>
16
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/reports" target="_blank" class="printful-quick-links-item">
17
  <span class="dashicons dashicons-chart-area"></span>
18
- <h4>Reports</h4>
19
  </a>
20
- <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/customer" target="_blank" class="printful-quick-links-item">
21
  <span class="dashicons dashicons-admin-users"></span>
22
- <h4>My Account</h4>
23
  </a>
24
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/billing" target="_blank" class="printful-quick-links-item">
25
  <span class="dashicons dashicons-portfolio"></span>
26
- <h4>Billing</h4>
27
  </a>
28
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/notifications" target="_blank" class="printful-quick-links-item">
29
  <span class="dashicons dashicons-megaphone"></span>
30
- <h4>Notifications</h4>
31
  </a>
32
  </div>
3
  <div class="printful-quick-links">
4
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard" target="_blank" class="printful-quick-links-item">
5
  <span class="dashicons dashicons-cart"></span>
6
+ <h4><?php esc_html_e('Orders', 'printful'); ?></h4>
7
  </a>
8
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/library" target="_blank" class="printful-quick-links-item">
9
  <span class="dashicons dashicons-images-alt"></span>
10
+ <h4><?php esc_html_e('File library', 'printful'); ?></h4>
11
  </a>
12
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/store" target="_blank" class="printful-quick-links-item">
13
  <span class="dashicons dashicons-store"></span>
14
+ <h4><?php esc_html_e('Stores', 'printful'); ?></h4>
15
  </a>
16
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/reports" target="_blank" class="printful-quick-links-item">
17
  <span class="dashicons dashicons-chart-area"></span>
18
+ <h4><?php esc_html_e('Reports', 'printful'); ?></h4>
19
  </a>
20
+ <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/settings/account-settings" target="_blank" class="printful-quick-links-item">
21
  <span class="dashicons dashicons-admin-users"></span>
22
+ <h4><?php esc_html_e('My Account', 'printful'); ?></h4>
23
  </a>
24
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/billing" target="_blank" class="printful-quick-links-item">
25
  <span class="dashicons dashicons-portfolio"></span>
26
+ <h4><?php esc_html_e('Billing', 'printful'); ?></h4>
27
  </a>
28
  <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>dashboard/notifications" target="_blank" class="printful-quick-links-item">
29
  <span class="dashicons dashicons-megaphone"></span>
30
+ <h4><?php esc_html_e('Notifications', 'printful'); ?></h4>
31
  </a>
32
  </div>
includes/templates/setting-group.php CHANGED
@@ -33,14 +33,14 @@
33
  <?php elseif ($setting['type'] == 'checkbox') : ?>
34
 
35
  <label for="<?php echo esc_attr($key); ?>">
36
- <input class="" type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($setting['value']); ?>" <?php if($setting['value'] == 'yes') { echo 'checked="checked"'; } ?>><?php echo esc_html($setting['label']); ?></label><br>
37
 
38
  <?php elseif ($setting['type'] == 'checkbox-group') : ?>
39
 
40
  <?php foreach ( $setting['items'] as $checkbox_key => $item ) : ?>
41
 
42
  <label for="<?php echo esc_attr($checkbox_key); ?>" class="checkbox-group-item">
43
- <input class="" type="checkbox" name="<?php echo esc_attr($key) . '[]'; ?>" id="<?php echo esc_attr($checkbox_key); ?>" value="<?php echo esc_attr($checkbox_key); ?>" <?php if ( $item['value'] == 'yes' ) {echo 'checked="checked"';} ?>><?php echo wp_kses_post( $item['label'] ); ?></label><br>
44
 
45
  <?php endforeach; ?>
46
 
33
  <?php elseif ($setting['type'] == 'checkbox') : ?>
34
 
35
  <label for="<?php echo esc_attr($key); ?>">
36
+ <input class="" type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" <?php if($setting['value'] == 'yes') { echo 'checked="checked"'; } ?>><?php echo esc_html($setting['label']); ?></label><br>
37
 
38
  <?php elseif ($setting['type'] == 'checkbox-group') : ?>
39
 
40
  <?php foreach ( $setting['items'] as $checkbox_key => $item ) : ?>
41
 
42
  <label for="<?php echo esc_attr($checkbox_key); ?>" class="checkbox-group-item">
43
+ <input class="" type="checkbox" name="<?php echo esc_attr($key) . '[]'; ?>" id="<?php echo esc_attr($checkbox_key); ?>" value="<?php echo esc_attr($checkbox_key); ?>" <?php if ( $item['value'] == 'yes' ) {echo 'checked="checked"';} ?>><?php echo wp_kses_post( $item['label'] ); ?></label><br>
44
 
45
  <?php endforeach; ?>
46
 
includes/templates/setting-submit.php CHANGED
@@ -1,16 +1,16 @@
1
  <p class="printful-submit">
2
- <input name="save" class="button-primary woocommerce-save-button <?php if($disabled) { echo 'disabled'; } ?>" type="submit" value="Save changes" <?php if($disabled) { echo 'disabled'; } ?>/>
3
  <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo esc_attr($nonce); ?>">
4
  <?php wp_referer_field(true); ?>
5
  <span class="loader-wrap">
6
  <img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ) ?>" class="loader" width="20px" height="20px" alt="loader"/>
7
  <span class="pass">
8
  <span class="dashicons dashicons-yes"></span>
9
- Saved successfully
10
  </span>
11
  <span class="fail">
12
  <span class="dashicons dashicons-no"></span>
13
- Saving settings failed
14
  </span>
15
  </span>
16
  </p>
1
  <p class="printful-submit">
2
+ <input name="save" class="button-primary woocommerce-save-button <?php if($disabled) { echo 'disabled'; } ?>" type="submit" value="<?php esc_attr_e('Save changes', 'printful'); ?>" <?php if($disabled) { echo 'disabled'; } ?>/>
3
  <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo esc_attr($nonce); ?>">
4
  <?php wp_referer_field(true); ?>
5
  <span class="loader-wrap">
6
  <img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ) ?>" class="loader" width="20px" height="20px" alt="loader"/>
7
  <span class="pass">
8
  <span class="dashicons dashicons-yes"></span>
9
+ <?php esc_html_e('Saved successfully', 'printful'); ?>
10
  </span>
11
  <span class="fail">
12
  <span class="dashicons dashicons-no"></span>
13
+ <?php esc_html_e('Saving settings failed', 'printful'); ?>
14
  </span>
15
  </span>
16
  </p>
includes/templates/shipping-notification.php CHANGED
@@ -1,4 +1,4 @@
1
  <div class="printful-setting-group">
2
- <h2>Printful Shipping</h2>
3
- <p>To enable/disable Printful shipping for your store go to <a href="<?php echo admin_url('admin.php?page=wc-settings&tab=shipping&section=printful_shipping'); ?>">WooCommerce Shipping settings</a>.</p>
4
  </div>
1
  <div class="printful-setting-group">
2
+ <h2><?php esc_html_e('Printful Shipping', 'printful'); ?></h2>
3
+ <p><?php esc_html_e('To enable/disable Printful shipping for your store go to', 'printful'); ?> <a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=shipping&section=printful_shipping' ) ); ?>"><?php esc_html_e('WooCommerce Shipping settings', 'printful'); ?></a>.</p>
4
  </div>
includes/templates/stats.php CHANGED
@@ -4,10 +4,10 @@
4
  <b>
5
  <?php
6
  echo esc_html($stats['orders_today']['orders']);
7
- echo ' ' . _n('ORDER', 'ORDERS', $stats['orders_today']['orders']);
8
  ?>
9
  </b>
10
- today
11
  </div>
12
  <div class="printful-stats-item">
13
  <h4>
@@ -17,10 +17,10 @@
17
  <b>
18
  <?php
19
  echo esc_html($stats['orders_last_7_days']['orders']);
20
- echo ' ' . _n('ORDER', 'ORDERS', $stats['orders_last_7_days']['orders']);
21
  ?>
22
  </b>
23
- last 7 days
24
  </div>
25
  <div class="printful-stats-item">
26
  <h4>
@@ -30,15 +30,15 @@
30
  <b>
31
  <?php
32
  echo esc_html($stats['orders_last_28_days']['orders']);
33
- echo ' ' . _n('ORDER', 'ORDERS', $stats['orders_last_28_days']['orders']);
34
  ?>
35
- </b> last 28 days
36
  </div>
37
  <div class="printful-stats-item">
38
  <h4>
39
  $<?php echo esc_attr($stats['profit_last_28_days']); ?>
40
  <?php echo '<span class="dashicons dashicons-arrow-' . esc_attr($stats['profit_trend_last_28_days']) .'-alt"></span>'; ?>
41
  </h4>
42
- <b>PROFIT</b> last 28 days
43
  </div>
44
  </div>
4
  <b>
5
  <?php
6
  echo esc_html($stats['orders_today']['orders']);
7
+ echo ' ' . _n('ORDER', 'ORDERS', $stats['orders_today']['orders'], 'printful' );
8
  ?>
9
  </b>
10
+ <?php esc_html_e('today', 'printful'); ?>
11
  </div>
12
  <div class="printful-stats-item">
13
  <h4>
17
  <b>
18
  <?php
19
  echo esc_html($stats['orders_last_7_days']['orders']);
20
+ echo ' ' . _n( 'ORDER', 'ORDERS', $stats['orders_last_7_days']['orders'], 'printful' );
21
  ?>
22
  </b>
23
+ <?php esc_html_e('last 7 days', 'printful'); ?>
24
  </div>
25
  <div class="printful-stats-item">
26
  <h4>
30
  <b>
31
  <?php
32
  echo esc_html($stats['orders_last_28_days']['orders']);
33
+ echo ' ' . _n( 'ORDER', 'ORDERS', $stats['orders_last_28_days']['orders'], 'printful' );
34
  ?>
35
+ </b> <?php esc_html_e('last 28 days', 'printful'); ?>
36
  </div>
37
  <div class="printful-stats-item">
38
  <h4>
39
  $<?php echo esc_attr($stats['profit_last_28_days']); ?>
40
  <?php echo '<span class="dashicons dashicons-arrow-' . esc_attr($stats['profit_trend_last_28_days']) .'-alt"></span>'; ?>
41
  </h4>
42
+ <b><?php esc_html_e('PROFIT', 'printful'); ?></b> <?php esc_html_e('last 28 days', 'printful'); ?>
43
  </div>
44
  </div>
includes/templates/status-report.php CHANGED
@@ -1,7 +1,7 @@
1
  <div class="support-report-wrap">
2
- <p>Copy the box content below and add it to your support message</p>
3
  <textarea class="support-report"><?php echo esc_html($status_report); ?></textarea>
4
- <button class="button button-primary button-large support-report-btn">Copy</button>
5
  <script type="text/javascript">
6
  var copyTextareaBtn = document.querySelector('.support-report-btn');
7
 
1
  <div class="support-report-wrap">
2
+ <p><?php esc_html_e('Copy the box content below and add it to your support message', 'printful'); ?></p>
3
  <textarea class="support-report"><?php echo esc_html($status_report); ?></textarea>
4
+ <button class="button button-primary button-large support-report-btn"><?php esc_html_e('Copy', 'printful'); ?></button>
5
  <script type="text/javascript">
6
  var copyTextareaBtn = document.querySelector('.support-report-btn');
7
 
includes/templates/status-table.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php if ( $checklist['overall_status'] ) {
2
  ?>
3
  <div class="notice notice-success">
4
- <p>Looks like the everything is set up correctly and Printful integration should work as intended.</p>
5
  </div>
6
  <?php
7
  } else {
8
  ?>
9
  <div class="notice notice-error">
10
- <p>There are errors with your store setup that may cause the Printful integration to not work as intended!</p>
11
  </div>
12
  <?php
13
  }
@@ -16,9 +16,9 @@
16
  <table class="wp-list-table widefat fixed striped printful-status">
17
  <thead>
18
  <tr>
19
- <td class="col-name">Name</td>
20
- <td class="col-desc">Description</td>
21
- <td class="col-status">Status</td>
22
  </tr>
23
  </thead>
24
  <tbody>
@@ -31,11 +31,11 @@
31
  <?php
32
  $status = 'OK';
33
  if ( $item['status'] == 1 ) {
34
- echo '<span class="pass">OK</span>';
35
  } else if ( $item['status'] == 0 ) {
36
- echo '<span class="warning">WARNING&#42;</span>';
37
  } else {
38
- echo '<span class="fail">FAIL</span>';
39
  }
40
  ?>
41
  </td>
@@ -44,11 +44,11 @@
44
  </tbody>
45
  <tfoot>
46
  <tr>
47
- <td class="col-name">Name</td>
48
- <td class="col-desc">Description</td>
49
- <td class="col-status">Status</td>
50
  </tr>
51
  </tfoot>
52
  </table>
53
 
54
- <p class="asterisk">&#42; Warnings are issued when the test was unable to come to a definite conclusion or if the result was passable, but not ideal.</p>
1
  <?php if ( $checklist['overall_status'] ) {
2
  ?>
3
  <div class="notice notice-success">
4
+ <p><?php esc_html_e('Looks like the everything is set up correctly and Printful integration should work as intended.', 'printful'); ?></p>
5
  </div>
6
  <?php
7
  } else {
8
  ?>
9
  <div class="notice notice-error">
10
+ <p><?php esc_html_e('There are errors with your store setup that may cause the Printful integration to not work as intended!', 'printful'); ?></p>
11
  </div>
12
  <?php
13
  }
16
  <table class="wp-list-table widefat fixed striped printful-status">
17
  <thead>
18
  <tr>
19
+ <td class="col-name"><?php esc_html_e('Name', 'printful'); ?></td>
20
+ <td class="col-desc"><?php esc_html_e('Description', 'printful'); ?></td>
21
+ <td class="col-status"><?php esc_html_e('Status', 'printful'); ?></td>
22
  </tr>
23
  </thead>
24
  <tbody>
31
  <?php
32
  $status = 'OK';
33
  if ( $item['status'] == 1 ) {
34
+ echo '<span class="pass">' . esc_html__('OK', 'printful') .'</span>';
35
  } else if ( $item['status'] == 0 ) {
36
+ echo '<span class="warning">' . esc_html__('WARNING', 'printful') .'&#42;</span>';
37
  } else {
38
+ echo '<span class="fail">' . esc_html__('FAIL', 'printful') .'</span>';
39
  }
40
  ?>
41
  </td>
44
  </tbody>
45
  <tfoot>
46
  <tr>
47
+ <td class="col-name"><?php esc_html_e('Name', 'printful'); ?></td>
48
+ <td class="col-desc"><?php esc_html_e('Description', 'printful'); ?></td>
49
+ <td class="col-status"><?php esc_html_e('Status', 'printful'); ?></td>
50
  </tr>
51
  </tfoot>
52
  </table>
53
 
54
+ <p class="asterisk">&#42; <?php esc_html_e('Warnings are issued when the test was unable to come to a definite conclusion or if the result was passable, but not ideal.', 'printful'); ?></p>
includes/templates/support-info.php CHANGED
@@ -1,26 +1,26 @@
1
  <div class="support-info-wrap">
2
 
3
  <div class="support-info-block">
4
- <h3>Need help? Get in touch!</h3>
5
- <p>Email, call, text, or visit us. We've got support teams in the USA and Europe to make sure we're there when you need us.<br/>We'd love to hear from you.</p>
6
  <div class="btn-wrap">
7
- <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>support" class="button button-primary button-large" target="_blank">Contact support</a>
8
  </div>
9
  </div>
10
 
11
  <div class="support-info-block">
12
- <h3>Read our FAQs</h3>
13
- <p>Getting started made easy – read the FAQs to jumpstart your business.<br/>Whether you're a video tutorial fan or prefer the written answers – we've got it covered!</p>
14
  <div class="btn-wrap">
15
- <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>faq" class="button button-primary button-large" target="_blank">See Printful FAQ</a>
16
  </div>
17
  </div>
18
 
19
  <div class="support-info-block">
20
- <h3>Integration help</h3>
21
- <p>Are you experiencing technical issues? Solve them on your own by reading these helpful guides and video tutorials.</p>
22
  <div class="btn-wrap">
23
- <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>faq/integrations/woocommerce" class="button button-primary button-large" target="_blank">Integration help</a>
24
  </div>
25
  </div>
26
 
1
  <div class="support-info-wrap">
2
 
3
  <div class="support-info-block">
4
+ <h3><?php esc_html_e('Need help? Get in touch!', 'printful') ?></h3>
5
+ <p><?php esc_html_e('Email, call, text, or visit us. We\'ve got support teams in the USA and Europe to make sure we\'re there when you need us.', 'printful') ?><br/><?php esc_html_e('We\'d love to hear from you.', 'printful') ?></p>
6
  <div class="btn-wrap">
7
+ <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>support" class="button button-primary button-large" target="_blank"><?php esc_html_e('Contact support', 'printful') ?></a>
8
  </div>
9
  </div>
10
 
11
  <div class="support-info-block">
12
+ <h3><?php esc_html_e('Read our FAQs', 'printful') ?></h3>
13
+ <p><?php esc_html_e('Getting started made easy – read the FAQs to jumpstart your business.', 'printful') ?><br/><?php esc_html_e('Whether you\'re a video tutorial fan or prefer the written answers – we\'ve got it covered!', 'printful') ?></p>
14
  <div class="btn-wrap">
15
+ <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>faq" class="button button-primary button-large" target="_blank"><?php esc_html_e('See Printful FAQ', 'printful') ?></a>
16
  </div>
17
  </div>
18
 
19
  <div class="support-info-block">
20
+ <h3><?php esc_html_e('Integration help', 'printful') ?></h3>
21
+ <p><?php esc_html_e('Are you experiencing technical issues? Solve them on your own by reading these helpful guides and video tutorials.', 'printful') ?></p>
22
  <div class="btn-wrap">
23
+ <a href="<?php echo esc_url(Printful_Base::get_printful_host()); ?>faq/integrations/woocommerce" class="button button-primary button-large" target="_blank"><?php esc_html_e('Integration help', 'printful') ?></a>
24
  </div>
25
  </div>
26
 
printful-shipping.php CHANGED
@@ -3,19 +3,24 @@
3
  Plugin Name: Printful Integration for WooCommerce
4
  Plugin URI: https://wordpress.org/plugins/printful-shipping-for-woocommerce/
5
  Description: Calculate correct shipping and tax rates for your Printful-Woocommerce integration.
6
- Version: 2.0.2
7
  Author: Printful
8
  Author URI: http://www.printful.com
9
  License: GPL2 http://www.gnu.org/licenses/gpl-2.0.html
 
10
  WC requires at least: 3.0.0
11
- WC tested up to: 3.3.0
12
  */
13
 
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
 
 
 
 
16
  class Printful_Base {
17
 
18
- const VERSION = '2.0.2';
19
  const PF_HOST = 'https://www.printful.com/';
20
  const PF_API_HOST = 'https://api.printful.com/';
21
 
@@ -24,6 +29,8 @@ class Printful_Base {
24
  */
25
  public function __construct() {
26
  add_action( 'plugins_loaded', array( $this, 'init' ) );
 
 
27
  }
28
 
29
  /**
@@ -54,6 +61,7 @@ class Printful_Base {
54
  require_once 'includes/class-printful-admin-support.php';
55
  require_once 'includes/class-printful-size-chart-tab.php';
56
  require_once 'includes/class-printful-size-chart-tab.php';
 
57
 
58
  //launch init
59
  Printful_Taxes::init();
@@ -72,6 +80,15 @@ class Printful_Base {
72
  add_action( 'wp_ajax_get_printful_carriers', array( 'Printful_Admin_Settings', 'render_carriers_ajax' ) );
73
  }
74
 
 
 
 
 
 
 
 
 
 
75
  /**
76
  * Added API endpoints
77
  * @param $endpoints
3
  Plugin Name: Printful Integration for WooCommerce
4
  Plugin URI: https://wordpress.org/plugins/printful-shipping-for-woocommerce/
5
  Description: Calculate correct shipping and tax rates for your Printful-Woocommerce integration.
6
+ Version: 2.0.3
7
  Author: Printful
8
  Author URI: http://www.printful.com
9
  License: GPL2 http://www.gnu.org/licenses/gpl-2.0.html
10
+ Text Domain: printful
11
  WC requires at least: 3.0.0
12
+ WC tested up to: 3.4.3
13
  */
14
 
15
  if ( ! defined( 'ABSPATH' ) ) exit;
16
 
17
+ if ( ! defined( 'PF_PLUGIN_FILE' ) ) {
18
+ define( 'PF_PLUGIN_FILE', __FILE__ );
19
+ }
20
+
21
  class Printful_Base {
22
 
23
+ const VERSION = '2.0.3';
24
  const PF_HOST = 'https://www.printful.com/';
25
  const PF_API_HOST = 'https://api.printful.com/';
26
 
29
  */
30
  public function __construct() {
31
  add_action( 'plugins_loaded', array( $this, 'init' ) );
32
+ add_action( 'plugins_loaded', array( $this, 'printful_load_plugin_textdomain') );
33
+ add_action( 'rest_api_init', array( 'Printful_REST_API', 'init' ) );
34
  }
35
 
36
  /**
61
  require_once 'includes/class-printful-admin-support.php';
62
  require_once 'includes/class-printful-size-chart-tab.php';
63
  require_once 'includes/class-printful-size-chart-tab.php';
64
+ require_once 'includes/class-printful-rest-api.php';
65
 
66
  //launch init
67
  Printful_Taxes::init();
80
  add_action( 'wp_ajax_get_printful_carriers', array( 'Printful_Admin_Settings', 'render_carriers_ajax' ) );
81
  }
82
 
83
+ /**
84
+ * Load Localisation files.
85
+ *
86
+ * Note: the first-loaded translation file overrides any following ones if the same translation is present.
87
+ */
88
+ public function printful_load_plugin_textdomain() {
89
+ load_plugin_textdomain( 'printful', false, plugin_basename( dirname( PF_PLUGIN_FILE ) ) . '/i18n/languages' );
90
+ }
91
+
92
  /**
93
  * Added API endpoints
94
  * @param $endpoints
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Printful Integration for WooCommerce ===
2
- Contributors: girts_u, kievins
3
  Tags: woocommerce, printful, drop shipping, shipping, shipping rates, fulfillment, printing, fedex, carriers, checkout, t-shirts
4
  Requires at least: 3.8
5
- Tested up to: 4.8
6
- Stable tag: 2.0.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -38,6 +38,9 @@ Go to https://www.printful.com/dashboard/store , select your WooCommerce store,
38
 
39
  == Upgrade Notice ==
40
 
 
 
 
41
  = 2.0.2 =
42
  Improved compatibility with WC 3.3.0
43
 
@@ -94,6 +97,11 @@ First release
94
 
95
  == Changelog ==
96
 
 
 
 
 
 
97
  = 2.0.2 =
98
  * Fixed incorrect webhook status indication since WC 3.3.0
99
 
1
  === Printful Integration for WooCommerce ===
2
+ Contributors: girts_u, kievins, kberzins
3
  Tags: woocommerce, printful, drop shipping, shipping, shipping rates, fulfillment, printing, fedex, carriers, checkout, t-shirts
4
  Requires at least: 3.8
5
+ Tested up to: 4.9
6
+ Stable tag: 2.0.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
38
 
39
  == Upgrade Notice ==
40
 
41
+ = 2.0.3 =
42
+ Fixed various minor issues, enabled localization, Improved compatibility with WC 3.4.3
43
+
44
  = 2.0.2 =
45
  Improved compatibility with WC 3.3.0
46
 
97
 
98
  == Changelog ==
99
 
100
+ = 2.0.3 =
101
+ * Improved compatibility with WC 3.3.5
102
+ * Wordpress localization support
103
+ * Minor bug fixes
104
+
105
  = 2.0.2 =
106
  * Fixed incorrect webhook status indication since WC 3.3.0
107