WooCommerce Square - Version 2.0.1

Version Description

  • 2019.07.23 =
  • Fix - Don't display the "unsupported" payment processing admin notice for UK-based merchants
Download this release

Release Info

Developer cshultz88
Plugin Icon 128x128 WooCommerce Square
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0.0 to 2.0.1

includes/Plugin.php CHANGED
@@ -41,7 +41,7 @@ class Plugin extends Framework\SV_WC_Payment_Gateway_Plugin {
41
42
43
/** plugin version number */
44
- const VERSION = '2.0.0';
45
46
/** plugin ID */
47
const PLUGIN_ID = 'square';
@@ -406,7 +406,7 @@ class Plugin extends Framework\SV_WC_Payment_Gateway_Plugin {
406
$accepted_countries = [
407
'US',
408
'CA',
409
- 'UK',
410
'AU',
411
'JP',
412
];
41
42
43
/** plugin version number */
44
+ const VERSION = '2.0.1';
45
46
/** plugin ID */
47
const PLUGIN_ID = 'square';
406
$accepted_countries = [
407
'US',
408
'CA',
409
+ 'GB',
410
'AU',
411
'JP',
412
];
includes/admin/Privacy.php DELETED
@@ -1,106 +0,0 @@
1
- <?php
2
- /**
3
- * WooCommerce Square
4
- *
5
- * This source file is subject to the GNU General Public License v3.0
6
- * that is bundled with this package in the file license.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.html
9
- * If you did not receive a copy of the license and are unable to
10
- * obtain it through the world-wide-web, please send an email
11
- * to license@woocommerce.com so we can send you a copy immediately.
12
- *
13
- * DISCLAIMER
14
- *
15
- * Do not edit or add to this file if you wish to upgrade WooCommerce Square to newer
16
- * versions in the future. If you wish to customize WooCommerce Square for your
17
- * needs please refer to https://docs.woocommerce.com/document/woocommerce-square/
18
- *
19
- * @author WooCommerce
20
- * @copyright Copyright: (c) 2019, Automattic, Inc.
21
- * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
22
- */
23
-
24
- namespace WooCommerce\Square\Admin;
25
-
26
- defined( 'ABSPATH' ) or exit;
27
-
28
- use SkyVerge\WooCommerce\PluginFramework\v5_4_0 as Framework;
29
-
30
- /**
31
- * Privacy admin handler.
32
- *
33
- * @since 2.0.0
34
- */
35
- class Privacy extends \WC_Abstract_Privacy {
36
-
37
-
38
- /**
39
- * Privacy class constructor.
40
- *
41
- * @since 2.0.0
42
- */
43
- public function __construct() {
44
-
45
-
46
- parent::__construct( __( 'Square', 'woocommerce-square' ) );
47
-
48
- $this->add_eraser( 'woocommerce-square-customer-data', __( 'WooCommerce Square Customer Data', 'woocommerce-square' ), [ $this, 'customer_data_eraser' ] );
49
- }
50
-
51
-
52
- /**
53
- * Gets the message to display.
54
- *
55
- * @since 2.0.0
56
- */
57
- public function get_message() {
58
-
59
- return wpautop(
60
- sprintf(
61
- /* translators: Placeholder: %1$s - <a> tag, %2$s - </a> tag */
62
- __( 'By using this extension, you may be storing personal data or sharing data with an external service. %1$sLearn more about how this works, including what you may want to include in your privacy policy.%2$s', 'woocommerce-square' ),
63
- '<a href="https://docs.woocommerce.com/document/privacy-payments/#woocommerce-square" target="_blank">', '</a>'
64
- )
65
- );
66
- }
67
-
68
-
69
- /**
70
- * Finds and erases customer data by email address.
71
- *
72
- * @since 2.0.0
73
- *
74
- * @param string $email_address the user email address
75
- * @param int $page page
76
- * @return array an array of personal data in name => value pairs
77
- */
78
- public function customer_data_eraser( $email_address, $page ) {
79
-
80
- // check if user has an ID to load stored personal data
81
- $user = get_user_by( 'email', $email_address );
82
- $square_customer_id = get_user_meta( $user->ID, 'wc_square_customer_id', true );
83
-
84
- $items_removed = false;
85
- $messages = [];
86
-
87
- if ( ! empty( $square_customer_id ) ) {
88
-
89
- $items_removed = true;
90
-
91
- delete_user_meta( $user->ID, 'wc_square_customer_id' );
92
-
93
- $messages[] = __( 'Square User Data Erased.', 'woocommerce-square' );
94
- }
95
-
96
- return [
97
- 'items_removed' => $items_removed,
98
- 'items_retained' => false,
99
- 'messages' => $messages,
100
- 'done' => true,
101
- ];
102
- }
103
-
104
-
105
- }
106
-
includes/admin/Products.php DELETED
@@ -1,663 +0,0 @@
1
- <?php
2
- /**
3
- * WooCommerce Square
4
- *
5
- * This source file is subject to the GNU General Public License v3.0
6
- * that is bundled with this package in the file license.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.html
9
- * If you did not receive a copy of the license and are unable to
10
- * obtain it through the world-wide-web, please send an email
11
- * to license@woocommerce.com so we can send you a copy immediately.
12
- *
13
- * DISCLAIMER
14
- *
15
- * Do not edit or add to this file if you wish to upgrade WooCommerce Square to newer
16
- * versions in the future. If you wish to customize WooCommerce Square for your
17
- * needs please refer to https://docs.woocommerce.com/document/woocommerce-square/
18
- *
19
- * @author WooCommerce
20
- * @copyright Copyright: (c) 2019, Automattic, Inc.
21
- * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
22
- */
23
-
24
- namespace WooCommerce\Square\Admin;
25
-
26
- defined( 'ABSPATH' ) or exit;
27
-
28
- use SkyVerge\WooCommerce\PluginFramework\v5_4_0 as Framework;
29
- use WooCommerce\Square\Handlers\Product;
30
- use WooCommerce\Square\Sync\Records;
31
-
32
- /**
33
- * Products admin handler.
34
- *
35
- * @since 2.0.0
36
- */
37
- class Products {
38
-
39
-
40
- /** @var array associative array of product error codes and messages */
41
- private $product_errors;
42
-
43
- /** @var array associative array of memoized errors being output for a product at one time */
44
- private $output_errors = [];
45
-
46
- /** @var int[] array of product IDs that have been scheduled for sync in this request */
47
- private $products_to_sync = [];
48
-
49
- /** @var int[] array of product IDs that have been scheduled for deletion in this request */
50
- private $products_to_delete = [];
51
-
52
-
53
- /**
54
- * Sets up the products admin handler.
55
- *
56
- * @since 2.0.0
57
- */
58
- public function __construct() {
59
-
60
- // add common errors
61
- $this->product_errors = [
62
- 'missing_sku' => __( "Please add a SKU to sync this product with Square. The SKU must match the item's SKU in your Square account.", 'woocommerce-square' ),
63
- 'missing_variation_sku' => __( "Please add a SKU to every variation of this variable product for syncing with Square. Each SKU must match the corresponding item's SKU in your Square account.", 'woocommerce-square' ),
64
- 'multiple_attributes' => __( 'Products with more than one attribute cannot be synced with Square.', 'woocommerce-square' ),
65
- 'custom_attributes' => __( 'Products with more than one custom attribute cannot be synced with Square. Remove the attribute(s) and update the product to dismiss this notice.', 'woocommerce-square' ),
66
- ];
67
-
68
- // add hooks
69
- $this->add_products_edit_screen_hooks();
70
- $this->add_product_edit_screen_hooks();
71
- $this->add_product_sync_hooks();
72
- }
73
-
74
-
75
- /**
76
- * Adds hooks to the admin products edit screen.
77
- *
78
- * Products filtering, bulk actions, etc.
79
- *
80
- * @since 2.0.0
81
- */
82
- private function add_products_edit_screen_hooks() {
83
-
84
- // adds an option to the "Filter by product type" dropdown
85
- add_action( 'restrict_manage_posts', [ $this, 'add_filter_products_synced_with_square_option' ] );
86
- // allow filtering products by sync status by altering results
87
- add_filter( 'request', [ $this, 'filter_products_synced_with_square' ] );
88
-
89
- // prevent copying Square data when duplicating a product automatically
90
- add_action( 'woocommerce_product_duplicate', [ $this, 'handle_product_duplication' ], 20, 2 );
91
-
92
- // handle quick/bulk edit actions in the products edit screen for setting sync status
93
- add_action( 'woocommerce_product_quick_edit_end', [ $this, 'add_quick_edit_inputs' ] );
94
- add_action( 'woocommerce_product_bulk_edit_end', [ $this, 'add_bulk_edit_inputs' ] );
95
- add_action( 'woocommerce_product_quick_edit_save', [ $this, 'set_synced_with_square' ] );
96
- add_action( 'woocommerce_product_bulk_edit_save', [ $this, 'set_synced_with_square' ] );
97
- }
98
-
99
-
100
- /**
101
- * Adds hooks to individual products edit screens.
102
- *
103
- * Product data input fields, variations, etc.
104
- *
105
- * @since 2.0.0
106
- */
107
- private function add_product_edit_screen_hooks() {
108
-
109
- // handle individual products input fields for setting sync status
110
- add_action( 'woocommerce_product_options_general_product_data', [ $this, 'add_product_data_fields' ] );
111
- add_action( 'woocommerce_admin_process_product_object', [ $this, 'process_product_data' ], 20 );
112
- add_action( 'woocommerce_before_product_object_save', [ $this, 'maybe_adjust_square_stock'] );
113
-
114
- add_action( 'admin_notices', [ $this, 'add_notice_product_hidden_from_catalog' ] );
115
- }
116
-
117
-
118
- /**
119
- * Adds hooks to sync products that have been updated.
120
- *
121
- * @since 2.0.0
122
- */
123
- private function add_product_sync_hooks() {
124
-
125
- add_action( 'woocommerce_update_product', [ $this, 'maybe_stage_product_for_sync' ] );
126
- add_action( 'trashed_post', [ $this, 'maybe_stage_products_for_deletion' ] );
127
- add_action( 'shutdown', [ $this, 'maybe_sync_staged_products' ] );
128
- add_action( 'shutdown', [ $this, 'maybe_delete_staged_products' ] );
129
- }
130
-
131
-
132
- /**
133
- * Adds an option to filter products by sync status.
134
- *
135
- * @internal
136
- *
137
- * @since 2.0.0
138
- *
139
- * @param string $post_type the post type context
140
- */
141
- public function add_filter_products_synced_with_square_option( $post_type ) {
142
-
143
- if ( 'product' !== $post_type ) {
144
- return;
145
- }
146
-
147
- $label = esc_html__( 'Synced with Square', 'woocommerce-square' );
148
- $selected = isset( $_GET['product_type'] ) && 'synced-with-square' === $_GET['product_type'] ? 'selected=\"selected\"' : '';
149
-
150
- wc_enqueue_js( "
151
- jQuery( document ).ready( function( $ ) {
152
- $( 'select#dropdown_product_type' ).append( '<option value=\"synced-with-square\" ' + '" . $selected . "' + '>' + '" . $label ."' + '</option>' );
153
- } );
154
- " );
155
- }
156
-
157
-
158
- /**
159
- * Filters products in admin edit screen by sync status with Square.
160
- *
161
- * @internal
162
- *
163
- * @since 2.0.0
164
- *
165
- * @param array $query_vars query variables
166
- * @return array
167
- */
168
- public function filter_products_synced_with_square( $query_vars ){
169
- global $typenow;
170
-
171
- if ( 'product' === $typenow && isset( $_GET['product_type'] ) && 'synced-with-square' === $_GET['product_type'] ) {
172
-
173
- // not really a product type, otherwise WooCommerce will handle it as such
174
- unset( $query_vars['product_type'] );
175
-
176
- if ( ! isset( $query_vars['tax_query'] ) ) {
177
- $query_vars['tax_query'] = [];
178
- } else {
179
- $query_vars['tax_query']['relation'] = 'AND';
180
- }
181
-
182
- $query_vars['tax_query'][] = [
183
- 'taxonomy' => Product::SYNCED_WITH_SQUARE_TAXONOMY,
184
- 'field' => 'slug',
185
- 'terms' => [ 'yes' ],
186
- ];
187
- }
188
-
189
- return $query_vars;
190
- }
191
-
192
-
193
- /**
194
- * Adds general product data options to a product metabox.
195
- *
196
- * @internal
197
- *
198
- * @since 2.0.0
199
- */
200
- public function add_product_data_fields() {
201
- global $product_object;
202
-
203
- if ( ! $product_object instanceof \WC_Product ) {
204
- return;
205
- }
206
-
207
- ?>
208
- <div class="wc-square-sync-with-square options_group show_if_simple show_if_variable">
209
- <?php
210
-
211
- $selector = '_' . Product::SYNCED_WITH_SQUARE_TAXONOMY;
212
- $value = Product::is_synced_with_square( $product_object ) ? 'yes' : 'no';
213
- $errors = [];
214
-
215
- if ( $product_object->is_type( 'variable' ) ) {
216
-
217
- $attributes = $product_object->get_attributes();
218
-
219
- if ( count( $attributes ) > 1 ) {
220
-
221
- /* @type \WC_Product_Attribute[] $attributes */
222
- foreach ( $attributes as $attribute ) {
223
-
224
- if ( ! $attribute->is_taxonomy() ) {
225
-
226
- $errors[] = 'custom_attributes';
227
- echo '<span style="display:none;" id="wc-square-has-multiple-custom-attributes"></span>';
228
- break;
229
- }
230
- }
231
-
232
- if ( ! in_array( 'custom_attributes', $errors, true ) ) {
233
- $errors[] = 'multiple_attributes';
234
- }
235
- }
236
-
237
- foreach ( $product_object->get_children() as $child ) {
238
-
239
- $child = wc_get_product( $child );
240
-
241
- if ( $child && ! $child->get_sku() ) {
242
- $errors[] = 'missing_variation_sku';
243
- }
244
- }
245
-
246
- } elseif ( ! $product_object->get_sku() ) {
247
-
248
- $errors[] = 'missing_sku';
249
- }
250
-
251
- $setting_label = wc_square()->get_settings_handler()->is_system_of_record_square() ? __( 'Update product data with Square data', 'woocommerce-square' ) : __( 'Send product data to Square', 'woocommerce-square' );
252
-
253
- woocommerce_wp_checkbox( [
254
- 'id' => $selector,
255
- 'label' => __( 'Sync with Square', 'woocommerce-square' ),
256
- 'value' => $value,
257
- 'cbvalue' => 'yes',
258
- 'default' => 'no',
259
- 'description' => $setting_label,
260
- 'custom_attributes' => ! empty( $errors ) ? [ 'disabled' => 'disabled' ] : [],
261
- ] );
262
-
263
- ?>
264
- <p class="form-field wc-square-sync-with-square-errors">
265
- <?php foreach ( $this->product_errors as $error_code => $error_message ) : ?>
266
- <?php $styles = ! in_array( $error_code, $errors, true ) ? 'display:none; color:#A00;' : 'display:block; color:#A00;'; ?>
267
- <span class="wc-square-sync-with-square-error <?php echo sanitize_html_class( $error_code ); ?>" style="<?php echo $styles; ?>"><?php echo esc_html( $error_message ); ?></span>
268
- <?php endforeach; ?>
269
- </p>
270
-
271
- <input type="hidden" id="<?php echo esc_attr( Product::SQUARE_VARIATION_ID_META_KEY ); ?>" value="<?php echo esc_attr( $product_object->get_meta( Product::SQUARE_VARIATION_ID_META_KEY ) ); ?>" />
272
-
273
- </div>
274
- <?php
275
- }
276
-
277
-
278
- /**
279
- * Outputs HTML with a dropdown field to mark a product to be synced with Square.
280
- *
281
- * @since 2.0.0
282
- *
283
- * @param bool $bulk whether the field is meant for bulk edit
284
- */
285
- private function output_synced_with_square_edit_field( $bulk = false ) {
286
-
287
- ?>
288
- <div class="inline-edit-group wc-square-sync-with-square">
289
- <label>
290
- <span class="title"><?php esc_html_e( 'Sync with Square?', 'woocommerce-square' ); ?></span>
291
- <span class="input-text-wrap">
292
- <select class="square-synced" name="<?php echo esc_attr( Product::SYNCED_WITH_SQUARE_TAXONOMY ); ?>">
293
- <?php if ( true === $bulk ) : // in bulk actions there's the option to leave the value unchanged (or unset) ?>
294
- <option value="">&mdash; <?php esc_html_e( 'No change', 'woocommerce-square' ); ?> &mdash;</option>
295
- <?php endif; ?>
296
- <option value="no"><?php esc_html_e( 'No', 'woocommerce-square' ); ?></option>
297
- <option value="yes"><?php esc_html_e( 'Yes', 'woocommerce-square' ); ?></option>
298
- </select>
299
- </span>
300
- </label>
301
- <p class="form-field wc-square-sync-with-square-errors">
302
- <?php foreach ( $this->product_errors as $error_code => $error_message ) : ?>
303
- <span class="wc-square-sync-with-square-error <?php echo $error_code; ?>" style="display:none; color:#A00;"><?php echo esc_html( $error_message ); ?></span>
304
- <?php endforeach; ?>
305
- </p>
306
- </div>
307
- <?php
308
- }
309
-
310
-
311
- /**
312
- * Adds quick edit fields to the products screen.
313
- *
314
- * @internal
315
- *
316
- * @since 2.0.0
317
- */
318
- public function add_quick_edit_inputs() {
319
-
320
- $this->output_synced_with_square_edit_field();
321
- }
322
-
323
-
324
- /**
325
- * Adds bulk edit fields to the products screen.
326
- *
327
- * @internal
328
- *
329
- * @since 2.0.0
330
- */
331
- public function add_bulk_edit_inputs() {
332
-
333
- $this->output_synced_with_square_edit_field( true );
334
- }
335
-
336
-
337
- /**
338
- * Stages a product for sync with Square on product save if Woo is the SOR and the product is set to 'synced with square'.
339
- *
340
- * @internal
341
- *
342
- * @since 2.0.0
343
- *
344
- * @param int $product_id the product ID
345
- */
346
- public function maybe_stage_product_for_sync( $product_id ) {
347
-
348
- if ( ! defined( 'DOING_SQUARE_SYNC' ) && ! in_array( $product_id, $this->products_to_sync ) && wc_square()->get_settings_handler()->is_system_of_record_woocommerce() ) {
349
-
350
- $product = wc_get_product( $product_id );
351
-
352
- if ( $product && Product::is_synced_with_square( $product ) ) {
353
-
354
- // the triggering action for this method can be called multiple times in a single request - keep track
355
- // of product IDs that have been scheduled for sync here to avoid multiple syncs on the same request
356
- $this->products_to_sync[] = $product_id;
357
- }
358
- }
359
- }
360
-
361
-
362
- /**
363
- * Initializes a synchronization event for any staged products in this request.
364
- *
365
- * @internal
366
- *
367
- * @since 2.0.0
368
- */
369
- public function maybe_sync_staged_products() {
370
-
371
- if ( ! defined( 'DOING_SQUARE_SYNC' ) && ! empty( $this->products_to_sync ) && wc_square()->get_settings_handler()->is_system_of_record_woocommerce() ) {
372
-
373
- wc_square()->get_sync_handler()->start_manual_sync( true, $this->products_to_sync );
374
- }
375
- }
376
-
377
-
378
- /**
379
- * Removes a product from Square if it is deleted locally and Woo is the SOR.
380
- *
381
- * @since 2.0.0
382
- *
383
- * @param int $product_id the product ID
384
- */
385
- public function maybe_stage_products_for_deletion( $product_id ) {
386
-
387
- if ( wc_square()->get_settings_handler()->is_system_of_record_woocommerce() ) {
388
-
389
- $product = wc_get_product( $product_id );
390
-
391
- if ( $product && Product::is_synced_with_square( $product ) ) {
392
-
393
- // the triggering action for this method can be called multiple times in a single request - keep track
394
- // of product IDs that have been scheduled for sync here to avoid multiple syncs on the same request
395
- $this->products_to_delete[] = $product_id;
396
- }
397
- }
398
- }
399
-
400
-
401
- /**
402
- * Deletes any products staged for remote deletion.
403
- *
404
- * @since 2.0.0
405
- */
406
- public function maybe_delete_staged_products() {
407
-
408
- if ( ! empty( $this->products_to_delete ) && wc_square()->get_settings_handler()->is_system_of_record_woocommerce() ) {
409
-
410
- wc_square()->get_sync_handler()->start_manual_deletion( $this->products_to_delete );
411
- }
412
- }
413
-
414
-
415
- /**
416
- * Sets a product's synced with Square status for quick/bulk edit action.
417
- *
418
- * @internal
419
- *
420
- * @since 2.0.0
421
- *
422
- * @param \WC_Product $product a product object
423
- */
424
- public function set_synced_with_square( $product ) {
425
-
426
- $posted_data_key = Product::SYNCED_WITH_SQUARE_TAXONOMY;
427
-
428
- if ( 'woocommerce_product_bulk_edit_save' === current_action() ) {
429
- $default_value = null; // in bulk actions this will preserve the existing setting if nothing is specified
430
- } else {
431
- $default_value = 'no'; // in individual products context, the value should be always an explicit yes or no
432
- }
433
-
434
- $square_synced = isset( $_REQUEST[ $posted_data_key ] ) && in_array( $_REQUEST[ $posted_data_key ], [ 'yes', 'no' ], true ) ? $_REQUEST[ $posted_data_key ] : $default_value;
435
-
436
- if ( is_string( $square_synced ) ) {
437
-
438
- Product::set_synced_with_square( $product, $square_synced );
439
- }
440
- }
441
-
442
-
443
- /**
444
- * Updates Square sync status for a product upon saving.
445
- *
446
- * @internal
447
- *
448
- * @since 2.0.0
449
- *
450
- * @param \WC_Product $product product object
451
- */
452
- public function process_product_data( $product ) {
453
-
454
- // bail if no valid product found, if it's a variation, errors have already been output
455
- if ( ! $product || ( $product instanceof \WC_Product_Variation || $product->is_type( 'product_variation' ) ) || ! empty( $this->output_errors[ $product->get_id() ] ) ) {
456
- return;
457
- }
458
-
459
- $errors = [];
460
- $posted_key = '_' . Product::SYNCED_WITH_SQUARE_TAXONOMY;
461
- $set_synced = isset( $_POST[ $posted_key ] ) && 'yes' === $_POST[ $posted_key ];
462
- $was_synced = Product::is_synced_with_square( $product );
463
-
464
- // condition has unchanged
465
- if ( ! $set_synced && ! $was_synced ) {
466
- return;
467
- }
468
-
469
- $is_variable = $product->is_type( 'variable' ) && $product->has_child();
470
-
471
- if ( $set_synced || $was_synced ) {
472
-
473
- if ( $is_variable ) {
474
-
475
- if ( isset( $this->product_errors['multiple_attributes'] ) && count( $product->get_attributes() ) > 1 ) {
476
- $errors['multiple_attributes'] = $this->product_errors['multiple_attributes'];
477
- }
478
-
479
- // if the product is variable, also its variations should have a matching SKU
480
- if ( isset( $this->product_errors['missing_variation_sku'] ) ) {
481
-
482
- foreach ( $product->get_children() as $variation_id ) {
483
-
484
- $variation = wc_get_product( $variation_id );
485
-
486
- if ( $variation && empty( $variation->get_sku() ) ) {
487
-
488
- $errors['missing_variation_sku'] = $this->product_errors['missing_variation_sku'];
489
- break;
490
- }
491
- }
492
- }
493
-
494
- } elseif ( isset( $this->product_errors['missing_sku'] ) && empty( $product->get_sku() ) ) {
495
-
496
- $errors['missing_sku'] = $this->product_errors['missing_sku'];
497
- }
498
- }
499
-
500
- if ( ! empty( $errors ) ) {
501
-
502
- // if the instruction is to sync the Product but there are errors, remove the link and display the errors
503
- Product::unset_synced_with_square( $product );
504
-
505
- foreach ( $errors as $error ) {
506
- wc_square()->get_message_handler()->add_error( $error );
507
- }
508
-
509
- } elseif ( $set_synced && $is_variable ) {
510
-
511
- // if there are no errors, and the product is variable, force enable stock management for all its variations
512
- foreach ( $product->get_children() as $variation_id ) {
513
-
514
- if ( $variation = wc_get_product( $variation_id ) ) {
515
- $variation->set_manage_stock( true );
516
- $variation->save();
517
- }
518
- }
519
- }
520
-
521
- // finally, set the product sync with Square flag
522
- Product::set_synced_with_square( $product, $set_synced ? 'yes' : 'no' );
523
- }
524
-
525
-
526
- /**
527
- * Adjusts a product's Square stock.
528
- *
529
- * @since 2.0.0
530
- *
531
- * @param \WC_Product $product product object
532
- */
533
- public function maybe_adjust_square_stock( $product ) {
534
-
535
- // this is hooked in to general product object save, so scope to specifically saving products via the admin
536
- if ( ! doing_action( 'wp_ajax_woocommerce_save_variations' ) && ! doing_action( 'woocommerce_admin_process_product_object' ) ) {
537
- return;
538
- }
539
-
540
- // only send stock updates for Woo SOR
541
- if ( ! wc_square()->get_settings_handler()->is_system_of_record_woocommerce() ) {
542
- return;
543
- }
544
-
545
- if ( ! $product instanceof \WC_Product || ! Product::is_synced_with_square( $product ) ) {
546
- return;
547
- }
548
-
549
- $product->set_manage_stock( true );
550
-
551
- $square_id = $product->get_meta( Product::SQUARE_VARIATION_ID_META_KEY );
552
-
553
- // only send when the product has an associated Square ID
554
- if ( ! $square_id ) {
555
- return;
556
- }
557
-
558
- $data = $product->get_data();
559
- $changes = $product->get_changes();
560
- $change = 0;
561
-
562
- if ( isset( $data['stock_quantity'], $changes['stock_quantity'] ) ) {
563
- $change = (int) $changes['stock_quantity'] - $data['stock_quantity'];
564
- }
565
-
566
- if ( $change !== 0 ) {
567
-
568
- try {
569
-
570
- if ( $change > 0 ) {
571
- wc_square()->get_api()->add_inventory( $square_id, $change );
572
- } else {
573
- wc_square()->get_api()->remove_inventory( $square_id, $change );
574
- }
575
-
576
- } catch ( Framework\SV_WC_Plugin_Exception $exception ) {
577
-
578
- $quantity = (float) $data['stock_quantity'];
579
-
580
- // if the API request fails, set the product quantity back from whence it came
581
- $product->set_stock_quantity( $quantity );
582
- }
583
- }
584
- }
585
-
586
-
587
- /**
588
- * Prevents copying Square data when duplicating a product in admin.
589
- *
590
- * @internal
591
- *
592
- * @since 2.0.0
593
- *
594
- * @param \WC_Product $duplicated_product product duplicate
595
- * @param \WC_Product $original_product product duplicated
596
- */
597
- public function handle_product_duplication( $duplicated_product, $original_product ) {
598
-
599
- if ( Product::is_synced_with_square( $original_product ) ) {
600
- Product::unset_synced_with_square( $duplicated_product );
601
- }
602
-
603
- $duplicated_product->delete_meta_data( Product::SQUARE_ID_META_KEY );
604
- $duplicated_product->delete_meta_data( Product::SQUARE_VARIATION_ID_META_KEY );
605
-
606
- if ( $duplicated_product->is_type( 'variable' ) ) {
607
-
608
- foreach ( $duplicated_product->get_children() as $duplicated_variation_id ) {
609
-
610
- if ( $duplicated_product_variation = wc_get_product( $duplicated_variation_id ) ) {
611
-
612
- $duplicated_product_variation->delete_meta_data( Product::SQUARE_VARIATION_ID_META_KEY );
613
- $duplicated_product_variation->save_meta_data();
614
- }
615
- }
616
- }
617
-
618
- $duplicated_product->save_meta_data();
619
- }
620
-
621
-
622
- /**
623
- * Outputs an admin notice when a product was hidden from catalog upon a sync error.
624
- *
625
- * @internal
626
- *
627
- * @since 2.0.0
628
- */
629
- public function add_notice_product_hidden_from_catalog() {
630
- global $current_screen, $post;
631
-
632
- if ( $post && $current_screen && 'product' === $current_screen->id ) {
633
-
634
- $product = wc_get_product( $post );
635
-
636
- if ( $product && 'hidden' === $product->get_catalog_visibility() ) {
637
-
638
- $product_id = $product->get_id();
639
- $records = Records::get_records( [ 'product' => $product_id ] );
640
-
641
- foreach ( $records as $record ) {
642
-
643
- if ( $record->was_product_hidden() && $product_id === $record->get_product_id() ) {
644
-
645
- wc_square()->get_message_handler()->add_warning(
646
- sprintf(
647
- /* translators: Placeholder: %1$s - date (localized), %2$s - time (localized), %3$s - opening <a> HTML link tag, %4$s closing </a> HTML link tag */
648
- esc_html__( 'The product catalog visibility has been set to "hidden", as a matching product could not be found in Square on %1$s at %2$s. %3$sCheck sync records%4$s.', 'woocommerce-square' ),
649
- date_i18n( wc_date_format(), $record->get_timestamp() ),
650
- date_i18n( wc_time_format(), $record->get_timestamp() ),
651
- '<a href="' . esc_url( add_query_arg( [ 'section' => 'update' ], wc_square()->get_settings_url() ) ) . '">', '</a>'
652
- )
653
- );
654
-
655
- break;
656
- }
657
- }
658
- }
659
- }
660
- }
661
-
662
-
663
- }
includes/admin/Settings_Page.php DELETED
@@ -1,197 +0,0 @@
1
- <?php
2
- /**
3
- * WooCommerce Square
4
- *
5
- * This source file is subject to the GNU General Public License v3.0
6
- * that is bundled with this package in the file license.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.html
9
- * If you did not receive a copy of the license and are unable to
10
- * obtain it through the world-wide-web, please send an email
11
- * to license@woocommerce.com so we can send you a copy immediately.
12
- *
13
- * DISCLAIMER
14
- *
15
- * Do not edit or add to this file if you wish to upgrade WooCommerce Square to newer
16
- * versions in the future. If you wish to customize WooCommerce Square for your
17
- * needs please refer to https://docs.woocommerce.com/document/woocommerce-square/
18
- *
19
- * @author WooCommerce
20
- * @copyright Copyright: (c) 2019, Automattic, Inc.
21
- * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
22
- */
23
-
24
- namespace WooCommerce\Square\Admin;
25
-
26
- defined( 'ABSPATH' ) or exit;
27
-
28
- use SkyVerge\WooCommerce\PluginFramework\v5_4_0 as Framework;
29
- use WooCommerce\Square;
30
-
31
- /**
32
- * The settings page class.
33
- *
34
- * @see \WooCommerce\Square\Settings handles settings registration
35
- *
36
- * @since 2.0.0
37
- */
38
- class Settings_Page extends \WC_Settings_Page {
39
-
40
-
41
- /** @var Square\Settings settings handler instance */
42
- protected $settings_handler;
43
-
44
-
45
- /**
46
- * Constructs the settings page.
47
- *
48
- * @since 2.0.0
49
- *
50
- * @param Square\Settings $settings_handler a settings handler instance, for displaying and saving the settings
51
- */
52
- public function __construct( Square\Settings $settings_handler ) {
53
-
54
- $this->id = Square\Plugin::PLUGIN_ID;
55
- $this->label = __( 'Square', 'woocommerce-square' );
56
- $this->settings_handler = $settings_handler;
57
-
58
- parent::__construct();
59
- }
60
-
61
-
62
- /**
63
- * Outputs the settings page.
64
- *
65
- * @internal
66
- *
67
- * @since 2.0.0
68
- */
69
- public function output() {
70
- global $current_section;
71
-
72
- if ( 'update' === $current_section ) {
73
- $this->output_update_section();
74
- } else {
75
- $this->output_general_section();
76
- }
77
- }
78
-
79
-
80
- /**
81
- * Outputs the general settings section.
82
- *
83
- * @since 2.0.0
84
- */
85
- private function output_general_section() {
86
-
87
- $this->settings_handler->admin_options();
88
- self::output_import_products_modal_template();
89
- }
90
-
91
-
92
- /**
93
- * Outputs the "Update" settings section.
94
- *
95
- * @since 2.0.0
96
- */
97
- private function output_update_section() {
98
- global $hide_save_button;
99
-
100
- // removes the save/update button from the screen
101
- $hide_save_button = true;
102
-
103
- Sync_Page::output();
104
- }
105
-
106
-
107
- /**
108
- * Saves the settings.
109
- *
110
- * @internal
111
- *
112
- * @since 2.0.0
113
- */
114
- public function save() {
115
-
116
- $this->settings_handler->process_admin_options();
117
- }
118
-
119
-
120
- /**
121
- * Gets the settings.
122
- *
123
- * @since 2.0.0
124
- *
125
- * @return array
126
- */
127
- public function get_settings() {
128
-
129
- return (array) apply_filters( 'woocommerce_get_settings_' . $this->get_id(), $this->settings_handler->get_form_fields() );
130
- }
131
-
132
-
133
- /**
134
- * Gets the settings sections.
135
- *
136
- * @internal
137
- *
138
- * @since 2.0.0
139
- *
140
- * @return array
141
- */
142
- public function get_sections() {
143
-
144
- $sections = [
145
- '' => __( 'Settings', 'woocommerce-square' ), // this key is intentionally blank
146
- 'update' => __( 'Update', 'woocommerce-square' ),
147
- ];
148
-
149
- /**
150
- * Filters the WooCommerce Square settings sections.
151
- *
152
- * @since 2.0.0
153
- *
154
- * @param array $sections settings sections
155
- */
156
- return (array) apply_filters( 'woocommerce_get_sections_' . $this->get_id(), $sections );
157
- }
158
-
159
-
160
- /**
161
- * Outputs a backbone modal template for importing products from Square.
162
- *
163
- * @since 2.0.0
164
- */
165
- private static function output_import_products_modal_template() {
166
-
167
- ?>
168
- <script type="text/template" id="tmpl-wc-square-import-products">
169
- <div class="wc-backbone-modal">
170
- <div class="wc-backbone-modal-content">
171
- <section class="wc-backbone-modal-main" role="main">
172
- <header class="wc-backbone-modal-header">
173
- <h1><?php esc_html_e( 'Import Products From Square', 'woocommerce-square' ); ?></h1>
174
- <button class="modal-close modal-close-link dashicons dashicons-no-alt">
175
- <span class="screen-reader-text"><?php esc_html_e( 'Close modal window', 'woocommerce-square' ); ?></span>
176
- </button>
177
- </header>
178
- <article>
179
- <?php /* translators: Placeholders: %1$s - <strong>, %2%s - </strong> */ ?>
180
- <?php printf( esc_html__( 'You are about to import all products from Square. This will create a new product in WooCommerce for every product retrieved from Square. %1$sOnly use this action to perform a one-time import!%2$s', 'woocommerce-square' ), '<strong>', '</strong>' ); ?>
181
- </article>
182
- <footer>
183
- <div class="inner">
184
- <button id="btn-close" class="button button-large"><?php esc_html_e( 'Cancel', 'woocommerce-square' ); ?></button>
185
- <button id="btn-ok" class="button button-large button-primary"><?php esc_html_e( 'Import Products', 'woocommerce-square' ); ?></button>
186
- </div>
187
- </footer>
188
- </section>
189
- </div>
190
- </div>
191
- <div class="wc-backbone-modal-backdrop modal-close"></div>
192
- </script>
193
- <?php
194
- }
195
-
196
-
197
- }
includes/admin/Sync_Page.php DELETED
@@ -1,379 +0,0 @@
1
- <?php
2
- /**
3
- * WooCommerce Square
4
- *
5
- * This source file is subject to the GNU General Public License v3.0
6
- * that is bundled with this package in the file license.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.html
9
- * If you did not receive a copy of the license and are unable to
10
- * obtain it through the world-wide-web, please send an email
11
- * to license@woocommerce.com so we can send you a copy immediately.
12
- *
13
- * DISCLAIMER
14
- *
15
- * Do not edit or add to this file if you wish to upgrade WooCommerce Square to newer
16
- * versions in the future. If you wish to customize WooCommerce Square for your
17
- * needs please refer to https://docs.woocommerce.com/document/woocommerce-square/
18
- *
19
- * @author WooCommerce
20
- * @copyright Copyright: (c) 2019, Automattic, Inc.
21
- * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
22
- */
23
-
24
- namespace WooCommerce\Square\Admin;
25
-
26
- defined( 'ABSPATH' ) or exit;
27
-
28
- use SkyVerge\WooCommerce\PluginFramework\v5_4_0 as Framework;
29
- use WooCommerce\Square\Handlers\Product;
30
- use WooCommerce\Square\Sync\Records;
31
-
32
- /**
33
- * Handles HTML output for the "Update" section of the Settings page with sync status handling and UI.
34
- *
35
- * @since 2.0.0
36
- */
37
- class Sync_Page {
38
-
39
-
40
- /**
41
- * Outputs the page HTML.
42
- *
43
- * @since 2.0.0
44
- */
45
- public static function output() {
46
-
47
- ?>
48
- <div id="wc-square-sync-page">
49
-
50
- <h2><?php esc_html_e( 'Update', 'woocommerce-sync' ); ?></h2>
51
- <?php self::output_system_record_of_data_info(); ?>
52
- <?php self::output_sync_status(); ?>
53
-
54
- <h2><?php esc_html_e( 'Sync records', 'woocommerce-sync' ); ?></h2>
55
- <?php self::output_sync_records(); ?>
56
- <?php self::output_sync_with_square_modal_template(); ?>
57
-
58
- </div>
59
- <?php
60
- }
61
-
62
-
63
- /**
64
- * Outputs notice-like tabular HTML with information on the current system of record handling.
65
- *
66
- * @since 2.0.0
67
- */
68
- private static function output_system_record_of_data_info() {
69
-
70
- ?>
71
- <table class="wc_square_table sor widefat" cellspacing="0">
72
- <tbody>
73
- <?php if ( wc_square()->get_settings_handler()->is_system_of_record_square() ) : ?>
74
-
75
- <tr>
76
- <td>
77
- <?php printf(
78
- /* translators: Placeholders: %1$s, %3$s - opening <strong> HTML tag, %2$s, $4%s - closing </strong> HTML tag */
79
- esc_html__( '%1$sSquare%2$s is the system of record. The following data from Square will overwrite WooCommerce data for synced products: %3$sname, price, inventory%4$s.', 'woocommerce-square' ),
80
- '<strong>', '</strong>', '<strong>', '</strong>'
81
- ); ?>
82
- </td>
83
- </tr>
84
- <tr>
85
- <td>
86
- <?php printf(
87
- /* translators: Placeholders: %1$s - opening <strong> HTML tag, %2$s closing </strong> HTML tag */
88
- esc_html__( '%1$sProduct images%2$s will be imported from Square if no featured image is set in WooCommerce.', 'woocommerce-square' ),
89
- '<strong>', '</strong>'
90
- );?>
91
- </td>
92
- </tr>
93
-
94
- <?php elseif ( wc_square()->get_settings_handler()->is_system_of_record_woocommerce() ) : ?>
95
-
96
- <tr>
97
- <td>
98
- <?php printf(
99
- /* translators: Placeholders: %1$s, %3$s - opening <strong> HTML tag, %2$s, %4$s - closing </strong> HTML tag */
100
- esc_html__( '%1$sWooCommerce%2$s is the system of record. The following data from WooCommerce will overwrite Square data for synced products: %3$sname, price, inventory, category, image%4$s.', 'woocommerce-square' ),
101
- '<strong>', '</strong>', '<strong>', '</strong>'
102
- ); ?>
103
- </td>
104
- </tr>
105
-
106
- <?php else : ?>
107
-
108
- <tr>
109
- <td>
110
- <?php printf(
111
- /* translators: Placeholders: %1$s - opening <strong> HTML tag, %2$s closing </strong> HTML tag*/
112
- esc_html__( '%1$sNo chosen system of record.%2$s Products will not be synced between Square and WooCommerce.', 'woocommerce-square' ),
113
- '<strong>', '</strong>'
114
- ); ?>
115
- </td>
116
- </tr>
117
-
118
- <?php endif; ?>
119
- </tbody>
120
- </table>
121
- <?php
122
- }
123
-
124
-
125
- /**
126
- * Outputs tabular HTML with information on sync status and a button to trigger a manual sync.
127
- *
128
- * @since 2.0.0
129
- */
130
- private static function output_sync_status() {
131
-
132
- $is_connected = wc_square()->get_settings_handler()->is_connected();
133
- $sync_in_progress = $is_connected ? wc_square()->get_sync_handler()->is_sync_in_progress() : false;
134
- $synced_products = wc_square()->get_settings_handler()->is_product_sync_enabled() ? Product::get_products_synced_with_square() : [];
135
- $synced_count = count( $synced_products );
136
- $is_product_import = false;
137
-
138
- if ( $sync_in_progress ) {
139
-
140
- $current_job = wc_square()->get_sync_handler()->get_job_in_progress();
141
- $is_product_import = isset( $current_job->action ) && 'product_import' === $current_job->action;
142
- }
143
-
144
- if ( ! $is_connected ) {
145
- $disabled_reason = esc_html__( 'Please connect to Square to enable product sync.', 'woocommerce-square' );
146
- } elseif ( 0 === $synced_count ) {
147
- $disabled_reason = esc_html__( 'There are currently no products marked to be synced with Square.', 'woocommerce-square' );
148
- } elseif ( $sync_in_progress ) {
149
- $disabled_reason = esc_html__( 'A sync is currently in progress. Please try again later.', 'woocommerce-square' );
150
- }
151
-
152
- if ( ! empty( $disabled_reason ) ) {
153
- /* translators: Placeholder: %s - reason text */
154
- $disabled_reason = sprintf( esc_html__( 'Product sync between WooCommerce and Square is currently unavailable. %s', 'woocommerce-square' ), $disabled_reason );
155
- }
156
-
157
- ?>
158
- <table class="wc_square_table sync widefat" cellspacing="0">
159
- <thead>
160
- <tr>
161
- <th class="synced-products"><?php esc_html_e( 'Synced products', 'woocommerce-square' ); ?></th>
162
- <th class="latest-sync"><?php esc_html_e( 'Latest sync', 'woocommerce-square' ); ?></th>
163
- <th class="next-sync"><?php esc_html_e( 'Next sync', 'woocommerce-square' ); ?></th>
164
- <th class="actions"><?php esc_html_e( 'Actions', 'woocommerce-square' ); ?></th>
165
- </tr>
166
- </thead>
167
- <tbody>
168
- <tr>
169
- <td class="synced-products">
170
- <a href="<?php echo esc_url( admin_url( 'edit.php?s&post_status=all&post_type=product&product_type=synced-with-square&stock_status&paged=1' ) ); ?>">
171
- <?php printf(
172
- /* translators: Placeholder: %d number of products synced with Square */
173
- _n( '%d product', '%d products', $synced_count, 'woocommerce-square' ),
174
- $synced_count
175
- ); ?>
176
- </a>
177
- <input
178
- type="hidden"
179
- id="wc-square-sync-products-count"
180
- value="<?php echo esc_attr( $synced_count ); ?>"
181
- />
182
- </td>
183
-
184
- <?php $date_time_format = wc_date_format() . ' ' . wc_time_format(); ?>
185
-
186
- <td class="latest-sync">
187
- <p class="sync-result">
188
- <?php if ( $sync_in_progress ) : ?>
189
- <?php if ( $is_product_import ) : ?>
190
- <em><?php esc_html_e( 'Importing now&hellip;', 'woocommerce-square' ); ?></em>
191
- <?php else : ?>
192
- <em><?php esc_html_e( 'Syncing now&hellip;', 'woocommerce-square' ); ?></em>
193
- <?php endif; ?>
194
- <?php else : ?>
195
-
196
- <?php if ( $last_synced_at = wc_square()->get_sync_handler()->get_last_synced_at() ) : ?>
197
-
198
- <?php
199
- $last_synced_date = new \DateTime();
200
- $last_synced_date->setTimestamp( $last_synced_at );
201
- $last_synced_date->setTimezone( new \DateTimeZone( wc_timezone_string() ) );
202
- ?>
203
-
204
- <?php echo esc_html( $last_synced_date->format( $date_time_format ) ); ?>
205
-
206
- <?php else : ?>
207
- <em><?php esc_html_e( 'Not synced yet.', 'woocommerce-square' ); ?></em>
208
- <?php endif; ?>
209
- <?php endif; ?>
210
- </p>
211
- </td>
212
- <td class="next-sync">
213
- <p>
214
- <?php if ( $sync_in_progress ) : ?>
215
- &mdash;
216
- <?php else : ?>
217
-
218
- <?php if ( $next_sync_at = wc_square()->get_sync_handler()->get_next_sync_at() ) : ?>
219
-
220
- <?php
221
- $next_sync_date = new \DateTime();
222
- $next_sync_date->setTimestamp( $next_sync_at );
223
- $next_sync_date->setTimezone( new \DateTimeZone( wc_timezone_string() ) );
224
- ?>
225
-
226
- <?php echo esc_html( $next_sync_date->format( $date_time_format ) ); ?>
227
-
228
- <?php else : ?>
229
- &mdash;
230
- <?php endif; ?>
231
- <?php endif; ?>
232
- </p>
233
- </td>
234
- <td class="actions">
235
- <button
236
- id="wc-square-sync"
237
- class="button button-large"
238
- <?php echo ! empty( $disabled_reason ) ? sprintf( 'disabled="disabled" title="%s"', esc_attr( $disabled_reason ) ) : ''; ?>
239
- ><?php esc_html_e( 'Sync now', 'woocommerce-square' ); ?></span></button>
240
- <div id="wc-square-sync-progress-spinner" class="spinner" style="float:none; <?php echo $sync_in_progress ? 'visibility:visible;' : ''; ?>"></div>
241
- </td>
242
- </tr>
243
- </tbody>
244
- </table>
245
- <?php
246
- }
247
-
248
-
249
- /**
250
- * Outputs tabular HTML with sync record logs and UI.
251
- *
252
- * @since 2.0.0
253
- */
254
- private static function output_sync_records() {
255
-
256
- $records = Records::get_records(); ?>
257
-
258
- <button
259
- id="wc-square_clear-sync-records"
260
- class="button button-large"
261
- <?php if ( empty( $records ) ) { echo 'disabled="disabled"'; } ?>
262
- ><?php echo esc_html_x( 'Clear history', 'Delete all records', 'woocommerce-square' ); ?></button>
263
-
264
- <table class="wc_square_table records widefat" cellspacing="0">
265
- <thead>
266
- <tr>
267
- <th class="date-time"><?php echo esc_html_x( 'Time', 'Date - Time', 'woocommerce-square' ); ?></th>
268
- <th class="type"><?php esc_html_e( 'Status', 'woocommerce-square' ); ?></th>
269
- <th class="message"><?php esc_html_e( 'Message', 'woocommerce-square' ); ?></th>
270
- <th class="actions"><?php esc_html_e( 'Actions', 'woocommerce-square' ); ?></th>
271
- </tr>
272
- </thead>
273
- <tbody>
274
- <?php if ( ! empty( $records ) ) : ?>
275
-
276
- <?php foreach ( $records as $record ) : ?>
277
-
278
- <tr id="record-<?php echo esc_attr( $record->get_id() ); ?>">
279
- <td class="date-time"><?php echo $record->get_local_date(); ?></td>
280
- <td class="type"><mark class="<?php echo esc_attr( sanitize_html_class( $record->get_type() ) ); ?>"><span><?php echo esc_html( $record->get_label() ); ?></span></mark></td>
281
- <td class="message"><?php echo wp_kses_post( $record->get_message() ); ?></td>
282
- <td class="actions">
283
- <?php foreach ( $record->get_actions() as $action ) : ?>
284
- <button
285
- class="button action <?php echo sanitize_html_class( $action->name ); ?> tips"
286
- data-id="<?php echo esc_attr( $record->get_id() ); ?>"
287
- data-action="<?php echo esc_attr( $action->name ); ?>"
288
- data-tip="<?php echo esc_attr( $action->label ); ?>"
289
- ><?php echo $action->icon; ?></button>
290
- <?php endforeach; ?>
291
- </td>
292
- </tr>
293
-
294
- <?php endforeach; ?>
295
-
296
- <?php else : ?>
297
-
298
- <tr>
299
- <td colspan="4">
300
- <em><?php esc_html_e( 'No records found.', 'woocommerce-square' ) ?></em>
301
- </td>
302
- </tr>
303
-
304
- <?php endif; ?>
305
- </tbody>
306
- <tfoot>
307
- <tr>
308
- <th class="date-time"><?php echo esc_html_x( 'Time', 'Date - Time', 'woocommerce-square' ); ?></th>
309
- <th class="type"><?php esc_html_e( 'Status', 'woocommerce-square' ); ?></th>
310
- <th class="message"><?php esc_html_e( 'Message', 'woocommerce-square' ); ?></th>
311
- <th class="actions"><?php esc_html_e( 'Actions', 'woocommerce-square' ); ?></th>
312
- </tr>
313
- </tfoot>
314
- </table>
315
- <?php
316
- }
317
-
318
-
319
- /**
320
- * Outputs a backbone modal template for starting a manual sync process.
321
- *
322
- * @since 2.0.0
323
- */
324
- private static function output_sync_with_square_modal_template() {
325
-
326
- ?>
327
- <script type="text/template" id="tmpl-wc-square-sync">
328
- <div class="wc-backbone-modal">
329
- <div class="wc-backbone-modal-content">
330
- <section class="wc-backbone-modal-main" role="main">
331
- <header class="wc-backbone-modal-header">
332
- <h1><?php esc_html_e( 'Sync products with Square', 'woocommerce-square' ); ?></h1>
333
- <button class="modal-close modal-close-link dashicons dashicons-no-alt">
334
- <span class="screen-reader-text"><?php esc_html_e( 'Close modal window', 'woocommerce-square' ); ?></span>
335
- </button>
336
- </header>
337
- <article>
338
- <?php $square_settings = wc_square()->get_settings_handler(); ?>
339
- <?php ob_start(); ?>
340
- <ul>
341
- <?php if ( $square_settings->is_system_of_record_square() ) : ?>
342
- <li><?php esc_html_e( 'If a match is found in Square, product data in WooCommerce will be overwritten with Square data.', 'woocommerce-square' ); ?></li>
343
- <?php elseif ( $square_settings->is_system_of_record_woocommerce() ) : ?>
344
- <li><?php esc_html_e( 'If a match is found in WooCommerce, product data in Square will be overwritten with WooCommerce data.', 'woocommerce-square' ); ?></li>
345
- <?php endif; ?>
346
- <?php if ( $square_settings->is_system_of_record_square() ) : ?>
347
- <?php if ( $square_settings->hide_missing_square_products() ) : ?>
348
- <li><?php esc_html_e( 'If a match is not found in Square, the product will be hidden from the catalog in WooCommerce.', 'woocommerce-square' ); ?></li>
349
- <?php else : ?>
350
- <li><?php esc_html_e( 'If a match is not found in Square, the product will be skipped in the sync.', 'woocommerce-square' ); ?></li>
351
- <?php endif; ?>
352
- <?php else : ?>
353
- <li><?php esc_html_e( 'If a match is not found, a new product will be created in Square.', 'woocommerce-square' ); ?></li>
354
- <?php endif; ?>
355
- </ul>
356
- <?php $additional_info = ob_get_clean(); ?>
357
- <?php printf(
358
- /* translators: Placeholders: %1$s - the system of record name (e.g. Square or WooCommerce), %3%s - unordered HTML list of additional information item(s) */
359
- esc_html__( 'You are about to sync products with Square. %1$s is your system of record. For all products synced with Square: %2$s', 'woocommerce-square' ),
360
- $square_settings->get_system_of_record_name(),
361
- $additional_info
362
- ); ?>
363
- </article>
364
- <footer>
365
- <div class="inner">
366
- <button id="btn-close" class="button button-large"><?php esc_html_e( 'Cancel', 'woocommerce-square' ); ?></button>
367
- <button id="btn-ok" class="button button-large button-primary"><?php esc_html_e( 'Start sync', 'woocommerce-square' ); ?></button>
368
- </div>
369
- </footer>
370
- </section>
371
- </div>
372
- </div>
373
- <div class="wc-backbone-modal-backdrop modal-close"></div>
374
- </script>
375
- <?php
376
- }
377
-
378
-
379
- }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: credit card, square, woocommerce, inventory sync
4
Requires at least: 4.6
5
Tested up to: 5.2.0
6
Requires PHP: 5.6
7
- Stable tag: 2.0.0
8
License: GPLv3
9
License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
@@ -72,6 +72,9 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
72
73
== Changelog ==
74
75
= 2.0.0 - 2019.07.22 =
76
* Feature - Support Square customer profiles for saved payment methods
77
* Feature - Customers can label their saved payment methods for easy identification when choosing how to pay
4
Requires at least: 4.6
5
Tested up to: 5.2.0
6
Requires PHP: 5.6
7
+ Stable tag: 2.0.1
8
License: GPLv3
9
License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
72
73
== Changelog ==
74
75
+ = 2.0.1 - 2019.07.23 =
76
+ * Fix - Don't display the "unsupported" payment processing admin notice for UK-based merchants
77
+
78
= 2.0.0 - 2019.07.22 =
79
* Feature - Support Square customer profiles for saved payment methods
80
* Feature - Customers can label their saved payment methods for easy identification when choosing how to pay
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
5
require_once __DIR__ . '/composer/autoload_real.php';
6
7
- return ComposerAutoloaderInit9bc8708bc6e6fe7ce2e37866264686ad::getLoader();
4
5
require_once __DIR__ . '/composer/autoload_real.php';
6
7
+ return ComposerAutoloaderInite107ddb09701c5bfa4c03e7854d385e4::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
3
// autoload_real.php @generated by Composer
4
5
- class ComposerAutoloaderInit9bc8708bc6e6fe7ce2e37866264686ad
6
{
7
private static $loader;
8
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit9bc8708bc6e6fe7ce2e37866264686ad
19
return self::$loader;
20
}
21
22
- spl_autoload_register(array('ComposerAutoloaderInit9bc8708bc6e6fe7ce2e37866264686ad', 'loadClassLoader'), true, true);
23
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit9bc8708bc6e6fe7ce2e37866264686ad', 'loadClassLoader'));
25
26
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
if ($useStaticLoader) {
28
require_once __DIR__ . '/autoload_static.php';
29
30
- call_user_func(\Composer\Autoload\ComposerStaticInit9bc8708bc6e6fe7ce2e37866264686ad::getInitializer($loader));
31
} else {
32
$map = require __DIR__ . '/autoload_namespaces.php';
33
foreach ($map as $namespace => $path) {
2
3
// autoload_real.php @generated by Composer
4
5
+ class ComposerAutoloaderInite107ddb09701c5bfa4c03e7854d385e4
6
{
7
private static $loader;
8
19
return self::$loader;
20
}
21
22
+ spl_autoload_register(array('ComposerAutoloaderInite107ddb09701c5bfa4c03e7854d385e4', 'loadClassLoader'), true, true);
23
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInite107ddb09701c5bfa4c03e7854d385e4', 'loadClassLoader'));
25
26
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
if ($useStaticLoader) {
28
require_once __DIR__ . '/autoload_static.php';
29
30
+ call_user_func(\Composer\Autoload\ComposerStaticInite107ddb09701c5bfa4c03e7854d385e4::getInitializer($loader));
31
} else {
32
$map = require __DIR__ . '/autoload_namespaces.php';
33
foreach ($map as $namespace => $path) {
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
5
namespace Composer\Autoload;
6
7
- class ComposerStaticInit9bc8708bc6e6fe7ce2e37866264686ad
8
{
9
public static $prefixLengthsPsr4 = array (
10
'S' =>
@@ -23,8 +23,8 @@ class ComposerStaticInit9bc8708bc6e6fe7ce2e37866264686ad
23
public static function getInitializer(ClassLoader $loader)
24
{
25
return \Closure::bind(function () use ($loader) {
26
- $loader->prefixLengthsPsr4 = ComposerStaticInit9bc8708bc6e6fe7ce2e37866264686ad::$prefixLengthsPsr4;
27
- $loader->prefixDirsPsr4 = ComposerStaticInit9bc8708bc6e6fe7ce2e37866264686ad::$prefixDirsPsr4;
28
29
}, null, ClassLoader::class);
30
}
4
5
namespace Composer\Autoload;
6
7
+ class ComposerStaticInite107ddb09701c5bfa4c03e7854d385e4
8
{
9
public static $prefixLengthsPsr4 = array (
10
'S' =>
23
public static function getInitializer(ClassLoader $loader)
24
{
25
return \Closure::bind(function () use ($loader) {
26
+ $loader->prefixLengthsPsr4 = ComposerStaticInite107ddb09701c5bfa4c03e7854d385e4::$prefixLengthsPsr4;
27
+ $loader->prefixDirsPsr4 = ComposerStaticInite107ddb09701c5bfa4c03e7854d385e4::$prefixDirsPsr4;
28
29
}, null, ClassLoader::class);
30
}
woocommerce-square.php CHANGED
@@ -1,7 +1,7 @@
1
<?php
2
/**
3
* Plugin Name: WooCommerce Square
4
- * Version: 2.0.0
5
* Plugin URI: https://woocommerce.com/products/square/
6
* Description: Adds ability to sync inventory between WooCommerce and Square POS. In addition, you can also make purchases through the Square payment gateway.
7
* Author: WooCommerce
1
<?php
2
/**
3
* Plugin Name: WooCommerce Square
4
+ * Version: 2.0.1
5
* Plugin URI: https://woocommerce.com/products/square/
6
* Description: Adds ability to sync inventory between WooCommerce and Square POS. In addition, you can also make purchases through the Square payment gateway.
7
* Author: WooCommerce