WooCommerce Square - Version 2.2.1

Version Description

  • 2020.09.11 =
  • New - Make the "Update existing products" part of the new import process optional by adding a new checkbox on Import Products modal. PR#508
  • Fix - Stop the import process from getting stuck in a loop when reaching the time limit. PR#511
  • Fix - Don't import/update categories from Square that are attached to products that cannot be found in WooCommerce. PR#511
  • Fix - "idempotency_key must not be greater than 45 length" errors returned by some payment requests on stores using custom order number plugins. PR#507
Download this release

Release Info

Developer automattic
Plugin Icon 128x128 WooCommerce Square
Version 2.2.1
Comparing to
See all releases

Code changes from version 2.2.0 to 2.2.1

assets/js/admin/wc-square-admin-settings.coffee CHANGED
@@ -92,10 +92,12 @@ jQuery( document ).ready ( $ ) ->
92
  'position': 'fixed'
93
  return
94
 
95
- data =
96
- action : 'wc_square_import_products_from_square'
97
- dispatch : wc_square_admin_settings.sync_in_background
98
- security : wc_square_admin_settings.import_products_from_square
 
 
99
 
100
  $.post wc_square_admin_settings.ajax_url, data, ( response ) ->
101
  message = if response.data then response.data else null
92
  'position': 'fixed'
93
  return
94
 
95
+ update_during_import = $( '#wc-square-import-product-updates' ).prop( 'checked' )
96
+ data =
97
+ action : 'wc_square_import_products_from_square'
98
+ dispatch : wc_square_admin_settings.sync_in_background
99
+ security : wc_square_admin_settings.import_products_from_square
100
+ update_during_import : update_during_import
101
 
102
  $.post wc_square_admin_settings.ajax_url, data, ( response ) ->
103
  message = if response.data then response.data else null
assets/js/admin/wc-square-admin-settings.min.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";(function(){jQuery(document).ready(function(e){var s,t,a,n;if(null!=(a=window.typenow)?a:"","woocommerce_page_wc-settings"===(null!=(n=window.pagenow)?n:""))return wc_square_admin_settings.is_sandbox||(e("#wc_square_sandbox_settings").hide(),e("#wc_square_sandbox_settings").next().hide(),e(".wc_square_sandbox_settings").closest("tr").hide()),e("#wc_square_system_of_record").change(function(){var s,t,a;return a=e(this).val(),s=e("#wc_square_enable_inventory_sync"),t=s.closest("tr"),"square"===a||"woocommerce"===a?(s.next("span").html(wc_square_admin_settings.i18n.sync_inventory_label[a]),t.find(".description").html(wc_square_admin_settings.i18n.sync_inventory_description[a]),t.show()):(s.prop("checked",!1),t.hide()),"square"===a?e("#wc_square_hide_missing_products").closest("tr").show():e("#wc_square_hide_missing_products").closest("tr").hide()}).change(),e(".js-import-square-products").on("click",function(s){return s.preventDefault(),new e.WCBackboneModal.View({target:"wc-square-import-products"}),e("#btn-close").on("click",function(s){return s.preventDefault(),e("button.modal-close").trigger("click")})}),e("#wc-square-sync").on("click",function(s){return s.preventDefault(),new e.WCBackboneModal.View({target:"wc-square-sync"}),e("#btn-close").on("click",function(s){return s.preventDefault(),e("button.modal-close").trigger("click")})}),e(document.body).on("wc_backbone_modal_response",function(s,t){var a;switch(t){case"wc-square-import-products":e("#wpbody").block({message:null,overlayCSS:{opacity:"0.2"},onBlock:function(){e(".blockUI.blockOverlay").css({position:"fixed"})}}),a={action:"wc_square_import_products_from_square",dispatch:wc_square_admin_settings.sync_in_background,security:wc_square_admin_settings.import_products_from_square},e.post(wc_square_admin_settings.ajax_url,a,function(e){var s;return(s=e.data?e.data:null)&&alert(s),location.reload()});break;case"wc-square-sync":e("table.sync").block({message:null,overlayCSS:{opacity:"0.2"}}),e("table.records").block({message:null,overlayCSS:{opacity:"0.2"}}),e("#wc-square_clear-sync-records").prop("disabled",!0),a={action:"wc_square_sync_products_with_square",dispatch:wc_square_admin_settings.sync_in_background,security:wc_square_admin_settings.sync_products_with_square},e.post(wc_square_admin_settings.ajax_url,a,function(s){return s&&s.success?location.reload():(e("#wc-square_clear-sync-records").prop("disabled",!1),e("table.sync").unblock(),e("table.records").unblock())});break;default:return}}),t='<tr><td colspan="4"><em>'+wc_square_admin_settings.i18n.no_records_found+"</em></td></tr>",e("#wc-square_clear-sync-records").on("click",function(s){var a;return s.preventDefault(),e("table.records").block({message:null,overlayCSS:{opacity:"0.2"}}),a={action:"wc_square_handle_sync_records",id:"all",handle:"delete",security:wc_square_admin_settings.handle_sync_with_square_records},e.post(wc_square_admin_settings.ajax_url,a,function(s){return s&&s.success?(e("table.records tbody").html(t),e("#wc-square_clear-sync-records").prop("disabled",!0)):(s.data&&alert(s.data),console.log(s)),e("table.records").unblock()})}),e(".records .actions button.action").on("click",function(s){var a,n,r;return s.preventDefault(),e("table.records").block({message:null,overlayCSS:{opacity:"0.2"}}),r=e(this).data("id"),a=e(this).data("action"),n={action:"wc_square_handle_sync_records",id:r,handle:a,security:wc_square_admin_settings.handle_sync_with_square_records},e.post(wc_square_admin_settings.ajax_url,n,function(s){var n;return s&&s.success?(n="#record-"+r,"delete"===a?(e(n).remove(),e("table.records tbody tr").length||(e("table.records tbody").html(t),e("#wc-square_clear-sync-records").prop("disabled",!0))):"resolve"!==a&&"unsync"!==a||(e(n+" .type").html('<mark class="resolved"><span>'+wc_square_admin_settings.i18n.resolved+"</span></mark>"),e(n+" .actions").html("&mdash;"))):(s&&s.data&&alert(s.data),console.log({record:r,action:a,response:s})),e("table.records").unblock()})}),e("form").submit(function(s){var t;return t=e("#wc_square_enable_sandbox").is(":checked")?"sandbox":"production",e(this).append(e("<input>",{type:"hidden",name:"wc_square_environment",value:t}))}),s=function(t){var a,n;return(a=e("span.progress"))&&0!==a.length||(e("p.sync-result").append(' <span class="progress" style="display:block"></span>'),a=e("span.progress")),n={action:"wc_square_get_sync_with_square_status",security:wc_square_admin_settings.get_sync_with_square_status_nonce,job_id:t},e.post(wc_square_admin_settings.ajax_url,n,function(t){var n,r;if(t&&t.data)return t.success&&t.data.id?(e("table.sync .spinner").css("visibility","visible"),e("#wc-square_clear-sync-records").prop("disabled",!0),e("table.records .actions button").prop("disabled",!0),"completed"!==(r=t.data.status)&&"failed"!==r?(n=" ","product_import"===t.data.action?(n+=wc_square_admin_settings.i18n.skipped+": "+parseInt(t.data.skipped_products_count,10)+"<br/>",n+=wc_square_admin_settings.i18n.updated+": "+parseInt(t.data.updated_products_count,10)+"<br/>",n+=wc_square_admin_settings.i18n.imported+": "+parseInt(t.data.imported_products_count,10)):t.data.percentage&&(n+=parseInt(t.data.percentage,10)+"%"),a.html(n),setTimeout(function(){return s(t.data.id)},3e4)):location.reload()):(e("#wc-square_clear-sync-records").prop("disabled",!1),e("table.records .actions button").prop("disabled",!1),e("table.sync .spinner").css("visibility","hidden"),console.log(t))})},wc_square_admin_settings.existing_sync_job_id?s(wc_square_admin_settings.existing_sync_job_id):void 0})}).call(void 0);
2
  //# sourceMappingURL=wc-square-admin-settings.min.js.map
1
+ "use strict";(function(){jQuery(document).ready(function(e){var s,t,a,r;if(null!=(a=window.typenow)?a:"","woocommerce_page_wc-settings"===(null!=(r=window.pagenow)?r:""))return wc_square_admin_settings.is_sandbox||(e("#wc_square_sandbox_settings").hide(),e("#wc_square_sandbox_settings").next().hide(),e(".wc_square_sandbox_settings").closest("tr").hide()),e("#wc_square_system_of_record").change(function(){var s,t,a;return a=e(this).val(),s=e("#wc_square_enable_inventory_sync"),t=s.closest("tr"),"square"===a||"woocommerce"===a?(s.next("span").html(wc_square_admin_settings.i18n.sync_inventory_label[a]),t.find(".description").html(wc_square_admin_settings.i18n.sync_inventory_description[a]),t.show()):(s.prop("checked",!1),t.hide()),"square"===a?e("#wc_square_hide_missing_products").closest("tr").show():e("#wc_square_hide_missing_products").closest("tr").hide()}).change(),e(".js-import-square-products").on("click",function(s){return s.preventDefault(),new e.WCBackboneModal.View({target:"wc-square-import-products"}),e("#btn-close").on("click",function(s){return s.preventDefault(),e("button.modal-close").trigger("click")})}),e("#wc-square-sync").on("click",function(s){return s.preventDefault(),new e.WCBackboneModal.View({target:"wc-square-sync"}),e("#btn-close").on("click",function(s){return s.preventDefault(),e("button.modal-close").trigger("click")})}),e(document.body).on("wc_backbone_modal_response",function(s,t){var a,r;switch(t){case"wc-square-import-products":e("#wpbody").block({message:null,overlayCSS:{opacity:"0.2"},onBlock:function(){e(".blockUI.blockOverlay").css({position:"fixed"})}}),r=e("#wc-square-import-product-updates").prop("checked"),a={action:"wc_square_import_products_from_square",dispatch:wc_square_admin_settings.sync_in_background,security:wc_square_admin_settings.import_products_from_square,update_during_import:r},e.post(wc_square_admin_settings.ajax_url,a,function(e){var s;return(s=e.data?e.data:null)&&alert(s),location.reload()});break;case"wc-square-sync":e("table.sync").block({message:null,overlayCSS:{opacity:"0.2"}}),e("table.records").block({message:null,overlayCSS:{opacity:"0.2"}}),e("#wc-square_clear-sync-records").prop("disabled",!0),a={action:"wc_square_sync_products_with_square",dispatch:wc_square_admin_settings.sync_in_background,security:wc_square_admin_settings.sync_products_with_square},e.post(wc_square_admin_settings.ajax_url,a,function(s){return s&&s.success?location.reload():(e("#wc-square_clear-sync-records").prop("disabled",!1),e("table.sync").unblock(),e("table.records").unblock())});break;default:return}}),t='<tr><td colspan="4"><em>'+wc_square_admin_settings.i18n.no_records_found+"</em></td></tr>",e("#wc-square_clear-sync-records").on("click",function(s){var a;return s.preventDefault(),e("table.records").block({message:null,overlayCSS:{opacity:"0.2"}}),a={action:"wc_square_handle_sync_records",id:"all",handle:"delete",security:wc_square_admin_settings.handle_sync_with_square_records},e.post(wc_square_admin_settings.ajax_url,a,function(s){return s&&s.success?(e("table.records tbody").html(t),e("#wc-square_clear-sync-records").prop("disabled",!0)):(s.data&&alert(s.data),console.log(s)),e("table.records").unblock()})}),e(".records .actions button.action").on("click",function(s){var a,r,n;return s.preventDefault(),e("table.records").block({message:null,overlayCSS:{opacity:"0.2"}}),n=e(this).data("id"),a=e(this).data("action"),r={action:"wc_square_handle_sync_records",id:n,handle:a,security:wc_square_admin_settings.handle_sync_with_square_records},e.post(wc_square_admin_settings.ajax_url,r,function(s){var r;return s&&s.success?(r="#record-"+n,"delete"===a?(e(r).remove(),e("table.records tbody tr").length||(e("table.records tbody").html(t),e("#wc-square_clear-sync-records").prop("disabled",!0))):"resolve"!==a&&"unsync"!==a||(e(r+" .type").html('<mark class="resolved"><span>'+wc_square_admin_settings.i18n.resolved+"</span></mark>"),e(r+" .actions").html("&mdash;"))):(s&&s.data&&alert(s.data),console.log({record:n,action:a,response:s})),e("table.records").unblock()})}),e("form").submit(function(s){var t;return t=e("#wc_square_enable_sandbox").is(":checked")?"sandbox":"production",e(this).append(e("<input>",{type:"hidden",name:"wc_square_environment",value:t}))}),s=function(t){var a,r;return(a=e("span.progress"))&&0!==a.length||(e("p.sync-result").append(' <span class="progress" style="display:block"></span>'),a=e("span.progress")),r={action:"wc_square_get_sync_with_square_status",security:wc_square_admin_settings.get_sync_with_square_status_nonce,job_id:t},e.post(wc_square_admin_settings.ajax_url,r,function(t){var r,n;if(t&&t.data)return t.success&&t.data.id?(e("table.sync .spinner").css("visibility","visible"),e("#wc-square_clear-sync-records").prop("disabled",!0),e("table.records .actions button").prop("disabled",!0),"completed"!==(n=t.data.status)&&"failed"!==n?(r=" ","product_import"===t.data.action?(r+=wc_square_admin_settings.i18n.skipped+": "+parseInt(t.data.skipped_products_count,10)+"<br/>",r+=wc_square_admin_settings.i18n.updated+": "+parseInt(t.data.updated_products_count,10)+"<br/>",r+=wc_square_admin_settings.i18n.imported+": "+parseInt(t.data.imported_products_count,10)):t.data.percentage&&(r+=parseInt(t.data.percentage,10)+"%"),a.html(r),setTimeout(function(){return s(t.data.id)},3e4)):location.reload()):(e("#wc-square_clear-sync-records").prop("disabled",!1),e("table.records .actions button").prop("disabled",!1),e("table.sync .spinner").css("visibility","hidden"),console.log(t))})},wc_square_admin_settings.existing_sync_job_id?s(wc_square_admin_settings.existing_sync_job_id):void 0})}).call(void 0);
2
  //# sourceMappingURL=wc-square-admin-settings.min.js.map
assets/js/admin/wc-square-admin-settings.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["wc-square-admin-settings.min.js"],"names":["jQuery","document","ready","$","_getSyncStatus","noRecordsFoundRow","ref","ref1","window","typenow","pagenow","wc_square_admin_settings","is_sandbox","hide","next","closest","change","$inventory_sync","$inventory_sync_row","system_of_record","this","val","html","i18n","sync_inventory_label","find","sync_inventory_description","show","prop","on","e","preventDefault","WCBackboneModal","View","target","trigger","body","data","block","message","overlayCSS","opacity","onBlock","css","position","action","dispatch","sync_in_background","security","import_products_from_square","post","ajax_url","response","alert","location","reload","sync_products_with_square","success","unblock","no_records_found","id","handle","handle_sync_with_square_records","console","log","recordId","rowId","remove","length","resolved","record","submit","environment","is","append","type","name","value","job_id","$progress","get_sync_with_square_status_nonce","progress","ref2","status","skipped","parseInt","skipped_products_count","updated","updated_products_count","imported","imported_products_count","percentage","setTimeout","existing_sync_job_id","call","undefined"],"mappings":"AAAA,cAEA,WAQEA,OAAOC,UAAUC,MAAM,SAAUC,GAQ/B,IAAIC,EAAgBC,EAA4BC,EAAKC,EAIrD,GAHoC,OAAzBD,EAAME,OAAOC,SAAmBH,EAAM,GAG7C,kCAFiC,OAA1BC,EAAOC,OAAOE,SAAmBH,EAAO,IAmQnD,OA9PKI,yBAAyBC,aAE5BT,EAAE,+BAA+BU,OACjCV,EAAE,+BAA+BW,OAAOD,OACxCV,EAAE,+BAA+BY,QAAQ,MAAMF,QAGjDV,EAAE,+BAA+Ba,OAAO,WACtC,IAAIC,EAAiBC,EAAqBC,EAc1C,OAbAA,EAAmBhB,EAAEiB,MAAMC,MAC3BJ,EAAkBd,EAAE,oCACpBe,EAAsBD,EAAgBF,QAAQ,MAErB,WAArBI,GAAsD,gBAArBA,GACnCF,EAAgBH,KAAK,QAAQQ,KAAKX,yBAAyBY,KAAKC,qBAAqBL,IACrFD,EAAoBO,KAAK,gBAAgBH,KAAKX,yBAAyBY,KAAKG,2BAA2BP,IACvGD,EAAoBS,SAEpBV,EAAgBW,KAAK,WAAW,GAChCV,EAAoBL,QAGlB,WAAaM,EACRhB,EAAE,oCAAoCY,QAAQ,MAAMY,OAEpDxB,EAAE,oCAAoCY,QAAQ,MAAMF,SAE5DG,SACHb,EAAE,8BAA8B0B,GAAG,QAAS,SAAUC,GAKpD,OAJAA,EAAEC,iBACF,IAAI5B,EAAE6B,gBAAgBC,MACpBC,OAAQ,8BAEH/B,EAAE,cAAc0B,GAAG,QAAS,SAAUC,GAE3C,OADA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iCyB,KAAK,YAAY,GACpDzB,EAAE,uBAAuBwC,IAAI,aAAc,UACpCoB,QAAQC,IAAIZ,OAMvBzC,yBAAyBkF,qBACpBzF,EAAeO,yBAAyBkF,2BADjD,MAIDC,UAAKC","file":"wc-square-admin-settings.min.js"}
1
+ {"version":3,"sources":["wc-square-admin-settings.min.js"],"names":["jQuery","document","ready","$","_getSyncStatus","noRecordsFoundRow","ref","ref1","window","typenow","pagenow","wc_square_admin_settings","is_sandbox","hide","next","closest","change","$inventory_sync","$inventory_sync_row","system_of_record","this","val","html","i18n","sync_inventory_label","find","sync_inventory_description","show","prop","on","e","preventDefault","WCBackboneModal","View","target","trigger","body","data","update_during_import","block","message","overlayCSS","opacity","onBlock","css","position","action","dispatch","sync_in_background","security","import_products_from_square","post","ajax_url","response","alert","location","reload","sync_products_with_square","success","unblock","no_records_found","id","handle","handle_sync_with_square_records","console","log","recordId","rowId","remove","length","resolved","record","submit","environment","is","append","type","name","value","job_id","$progress","get_sync_with_square_status_nonce","progress","ref2","status","skipped","parseInt","skipped_products_count","updated","updated_products_count","imported","imported_products_count","percentage","setTimeout","existing_sync_job_id","call","undefined"],"mappings":"AAAA,cAEA,WAQEA,OAAOC,UAAUC,MAAM,SAAUC,GAQ/B,IAAIC,EAAgBC,EAA4BC,EAAKC,EAIrD,GAHoC,OAAzBD,EAAME,OAAOC,SAAmBH,EAAM,GAG7C,kCAFiC,OAA1BC,EAAOC,OAAOE,SAAmBH,EAAO,IAqQnD,OAhQKI,yBAAyBC,aAE5BT,EAAE,+BAA+BU,OACjCV,EAAE,+BAA+BW,OAAOD,OACxCV,EAAE,+BAA+BY,QAAQ,MAAMF,QAGjDV,EAAE,+BAA+Ba,OAAO,WACtC,IAAIC,EAAiBC,EAAqBC,EAc1C,OAbAA,EAAmBhB,EAAEiB,MAAMC,MAC3BJ,EAAkBd,EAAE,oCACpBe,EAAsBD,EAAgBF,QAAQ,MAErB,WAArBI,GAAsD,gBAArBA,GACnCF,EAAgBH,KA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,mBAAqB7B,EAAShB,KAAKS,QACrCoC,GAAYvE,yBAAyBY,KAAK8D,QAAU,KAAOC,SAASjC,EAAShB,KAAKkD,uBAAwB,IAAM,QAChHL,GAAYvE,yBAAyBY,KAAKiE,QAAU,KAAOF,SAASjC,EAAShB,KAAKoD,uBAAwB,IAAM,QAChHP,GAAYvE,yBAAyBY,KAAKmE,SAAW,KAAOJ,SAASjC,EAAShB,KAAKsD,wBAAyB,KACnGtC,EAAShB,KAAKuD,aACvBV,GAAYI,SAASjC,EAAShB,KAAKuD,WAAY,IAAM,KAEvDZ,EAAU1D,KAAK4D,GAERW,WAAW,WAChB,OAAOzF,EAAeiD,EAAShB,KAAKwB,KACnC,MAGIN,SAASC,WAGlBrD,EAAE,iCAAiCyB,KAAK,YAAY,GACpDzB,EAAE,iCAAiCyB,KAAK,YAAY,GACpDzB,EAAE,uBAAuByC,IAAI,aAAc,UACpCoB,QAAQC,IAAIZ,OAMvB1C,yBAAyBmF,qBACpB1F,EAAeO,yBAAyBmF,2BADjD,MAIDC,UAAKC","file":"wc-square-admin-settings.min.js"}
i18n/languages/woocommerce-square.pot CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the GNU General Public License v3.0.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WooCommerce Square 2.2.0\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://github.com/woocommerce/woocommerce-square/issues\n"
8
- "POT-Creation-Date: 2020-08-31 01:32:52+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -111,20 +111,33 @@ msgid ""
111
  "You are about to import all new products, variations and categories from "
112
  "Square. This will create a new product in WooCommerce for every product "
113
  "retrieved from Square. If you have products in the trash from the previous "
114
- "imports, these will be ignored in the import. During this process, simple "
115
- "products that have new variations found in Sqaure will be converted to a "
116
- "variable product in WooCommerce. %1$sOnly use this action to perform a "
117
- "one-time import!%2$s"
118
  msgstr ""
119
 
120
- #: includes/Admin/Settings_Page.php:184 includes/Admin/Sync_Page.php:393
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  #: vendor/prospress/action-scheduler/classes/ActionScheduler_ListTable.php:133
122
  #: vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/admin/views/html-order-partial-capture.php:66
123
  #: vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php:227
124
  msgid "Cancel"
125
  msgstr ""
126
 
127
- #: includes/Admin/Settings_Page.php:185 includes/Settings.php:244
128
  msgid "Import Products"
129
  msgstr ""
130
 
@@ -570,7 +583,7 @@ msgid ""
570
  "records%4$s."
571
  msgstr ""
572
 
573
- #: includes/Handlers/Sync.php:327
574
  #. translators: Placeholder: %d number of products processed
575
  msgid "Updated data for %d product."
576
  msgid_plural "Updated data for %d products."
@@ -872,41 +885,41 @@ msgstr[1] ""
872
  msgid "Product %s could not be updated in Square."
873
  msgstr ""
874
 
875
- #: includes/Sync/Product_Import.php:521
876
  #. translators: Placeholders: %1$s - Square item name, %2$s - Square item
877
  #. variation name, %3$s - failure reason
878
  msgid "Could not import \"%1$s - %2$s\" from Square. %3$s"
879
  msgstr ""
880
 
881
- #: includes/Sync/Product_Import.php:572
882
  msgid "Items with variable pricing cannot be imported."
883
  msgstr ""
884
 
885
- #: includes/Sync/Product_Import.php:665 includes/Sync/Product_Import.php:936
886
  msgid "The SKU already exists on another product"
887
  msgstr ""
888
 
889
- #: includes/Sync/Product_Import.php:852
890
  #. translators: Placeholders: %1$s - variation ID, %2$s - product name
891
  msgid "Variation #%1$s of %2$s"
892
  msgstr ""
893
 
894
- #: includes/Sync/Product_Import.php:1230
895
  #. translators: Placeholders: %s - missing parameter name
896
  msgid "Missing parameter %s"
897
  msgstr ""
898
 
899
- #: includes/Sync/Product_Import.php:1236
900
  #. translators: Placeholders: %s - comma separated list of valid product types
901
  msgid "Invalid product type - the product type must be any of these: %s"
902
  msgstr ""
903
 
904
- #: includes/Sync/Product_Import.php:1287
905
  #. translators: Placeholders: %1$s - Square item name, %2$s - Failure reason
906
  msgid "Could not update %1$s from Square. %2$s"
907
  msgstr ""
908
 
909
- #: includes/Sync/Product_Import.php:1290
910
  #. translators: Placeholders: %1$s - Square item name, %2$s - Failure reason
911
  msgid "Could not import %1$s from Square. %2$s"
912
  msgstr ""
2
  # This file is distributed under the GNU General Public License v3.0.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce Square 2.2.1\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://github.com/woocommerce/woocommerce-square/issues\n"
8
+ "POT-Creation-Date: 2020-09-10 22:27:44+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
111
  "You are about to import all new products, variations and categories from "
112
  "Square. This will create a new product in WooCommerce for every product "
113
  "retrieved from Square. If you have products in the trash from the previous "
114
+ "imports, these will be ignored in the import."
 
 
 
115
  msgstr ""
116
 
117
+ #: includes/Admin/Settings_Page.php:182
118
+ msgid "Do you wish to import existing product updates from Square?"
119
+ msgstr ""
120
+
121
+ #: includes/Admin/Settings_Page.php:184
122
+ #. translators: Placeholders: %1$s - <a> tag linking to WooCommerce Square
123
+ #. docs, %2%s - closing </a> tag
124
+ msgid ""
125
+ "Doing so will update existing WooCommerce products with the latest "
126
+ "information from Square. %1$sView Documentation%2$s."
127
+ msgstr ""
128
+
129
+ #: includes/Admin/Settings_Page.php:185
130
+ msgid "Update existing products during import."
131
+ msgstr ""
132
+
133
+ #: includes/Admin/Settings_Page.php:189 includes/Admin/Sync_Page.php:393
134
  #: vendor/prospress/action-scheduler/classes/ActionScheduler_ListTable.php:133
135
  #: vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/admin/views/html-order-partial-capture.php:66
136
  #: vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php:227
137
  msgid "Cancel"
138
  msgstr ""
139
 
140
+ #: includes/Admin/Settings_Page.php:190 includes/Settings.php:244
141
  msgid "Import Products"
142
  msgstr ""
143
 
583
  "records%4$s."
584
  msgstr ""
585
 
586
+ #: includes/Handlers/Sync.php:329
587
  #. translators: Placeholder: %d number of products processed
588
  msgid "Updated data for %d product."
589
  msgid_plural "Updated data for %d products."
885
  msgid "Product %s could not be updated in Square."
886
  msgstr ""
887
 
888
+ #: includes/Sync/Product_Import.php:529
889
  #. translators: Placeholders: %1$s - Square item name, %2$s - Square item
890
  #. variation name, %3$s - failure reason
891
  msgid "Could not import \"%1$s - %2$s\" from Square. %3$s"
892
  msgstr ""
893
 
894
+ #: includes/Sync/Product_Import.php:580
895
  msgid "Items with variable pricing cannot be imported."
896
  msgstr ""
897
 
898
+ #: includes/Sync/Product_Import.php:673 includes/Sync/Product_Import.php:944
899
  msgid "The SKU already exists on another product"
900
  msgstr ""
901
 
902
+ #: includes/Sync/Product_Import.php:860
903
  #. translators: Placeholders: %1$s - variation ID, %2$s - product name
904
  msgid "Variation #%1$s of %2$s"
905
  msgstr ""
906
 
907
+ #: includes/Sync/Product_Import.php:1238
908
  #. translators: Placeholders: %s - missing parameter name
909
  msgid "Missing parameter %s"
910
  msgstr ""
911
 
912
+ #: includes/Sync/Product_Import.php:1244
913
  #. translators: Placeholders: %s - comma separated list of valid product types
914
  msgid "Invalid product type - the product type must be any of these: %s"
915
  msgstr ""
916
 
917
+ #: includes/Sync/Product_Import.php:1295
918
  #. translators: Placeholders: %1$s - Square item name, %2$s - Failure reason
919
  msgid "Could not update %1$s from Square. %2$s"
920
  msgstr ""
921
 
922
+ #: includes/Sync/Product_Import.php:1298
923
  #. translators: Placeholders: %1$s - Square item name, %2$s - Failure reason
924
  msgid "Could not import %1$s from Square. %2$s"
925
  msgstr ""
includes/AJAX.php CHANGED
@@ -142,7 +142,7 @@ class AJAX {
142
 
143
  check_ajax_referer( 'import-products-from-square', 'security' );
144
 
145
- $started = wc_square()->get_sync_handler()->start_product_import( ! empty( $_POST['dispatch'] ) );
146
 
147
  if ( ! $started ) {
148
  wp_send_json_error( __( 'Could not start import. Please try again.', 'woocommerce-square' ) );
142
 
143
  check_ajax_referer( 'import-products-from-square', 'security' );
144
 
145
+ $started = wc_square()->get_sync_handler()->start_product_import( ! empty( $_POST['dispatch'] ), ( ! empty( $_POST['update_during_import'] ) && 'true' === $_POST['update_during_import'] ) );
146
 
147
  if ( ! $started ) {
148
  wp_send_json_error( __( 'Could not start import. Please try again.', 'woocommerce-square' ) );
includes/Admin/Settings_Page.php CHANGED
@@ -177,7 +177,12 @@ class Settings_Page extends \WC_Settings_Page {
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 new products, variations and categories from Square. This will create a new product in WooCommerce for every product retrieved from Square. If you have products in the trash from the previous imports, these will be ignored in the import. During this process, simple products that have new variations found in Sqaure will be converted to a variable product in WooCommerce. %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">
177
  </header>
178
  <article>
179
  <?php /* translators: Placeholders: %1$s - <strong>, %2%s - </strong> */ ?>
180
+ <p><?php printf( esc_html__( 'You are about to import all new products, variations and categories from Square. This will create a new product in WooCommerce for every product retrieved from Square. If you have products in the trash from the previous imports, these will be ignored in the import.', 'woocommerce-square' ), '<strong>', '</strong>' ); ?></p>
181
+ <hr>
182
+ <h4><?php esc_html_e( 'Do you wish to import existing product updates from Square?', 'woocommerce-square' ); ?></h4>
183
+ <?php /* translators: Placeholders: %1$s - <a> tag linking to WooCommerce Square docs, %2%s - closing </a> tag */ ?>
184
+ <p><?php printf( esc_html__( 'Doing so will update existing WooCommerce products with the latest information from Square. %1$sView Documentation%2$s.', 'woocommerce-square' ), '<a href="https://docs.woocommerce.com/document/woocommerce-square/#section-4">', '</a>' ); ?></p>
185
+ <label for="wc-square-import-product-updates"><input type="checkbox" id="wc-square-import-product-updates" /><?php esc_html_e( 'Update existing products during import.', 'woocommerce-square' ); ?></label>
186
  </article>
187
  <footer>
188
  <div class="inner">
includes/Gateway.php CHANGED
@@ -896,4 +896,28 @@ class Gateway extends Framework\SV_WC_Payment_Gateway_Direct {
896
  exit;
897
  }
898
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
899
  }
896
  exit;
897
  }
898
 
899
+ /**
900
+ * Returns the $order object with a unique transaction ref member added
901
+ *
902
+ * @since 2.2.1
903
+ * @param WC_Order $order the order object
904
+ * @return WC_Order order object with member named unique_transaction_ref
905
+ */
906
+ protected function get_order_with_unique_transaction_ref( $order ) {
907
+ $order_id = $order->get_id();
908
+
909
+ // generate a unique retry count
910
+ if ( is_numeric( $this->get_order_meta( $order_id, 'retry_count' ) ) ) {
911
+ $retry_count = $this->get_order_meta( $order_id, 'retry_count' );
912
+ $retry_count++;
913
+ } else {
914
+ $retry_count = 0;
915
+ }
916
+
917
+ // keep track of the retry count
918
+ $this->update_order_meta( $order, 'retry_count', $retry_count );
919
+
920
+ $order->unique_transaction_ref = $order_id . ( $retry_count >= 0 ? '_' . $retry_count : '' );
921
+ return $order;
922
+ }
923
  }
includes/Handlers/Sync.php CHANGED
@@ -138,13 +138,15 @@ class Sync {
138
  * @since 2.0.0
139
  *
140
  * @param bool $dispatch whether the job should be immediately dispatched
 
141
  * @return \stdClass|null
142
  */
143
- public function start_product_import( $dispatch = true ) {
144
 
145
  $job = $this->get_plugin()->get_background_job_handler()->create_job(
146
  array(
147
- 'action' => 'product_import',
 
148
  )
149
  );
150
 
138
  * @since 2.0.0
139
  *
140
  * @param bool $dispatch whether the job should be immediately dispatched
141
+ * @param bool $update_during_import whether the store manager has ticked to update products during an import
142
  * @return \stdClass|null
143
  */
144
+ public function start_product_import( $dispatch = true, $update_during_import = false ) {
145
 
146
  $job = $this->get_plugin()->get_background_job_handler()->create_job(
147
  array(
148
+ 'action' => 'product_import',
149
+ 'update_products_during_import' => $update_during_import,
150
  )
151
  );
152
 
includes/Plugin.php CHANGED
@@ -42,7 +42,7 @@ class Plugin extends Framework\SV_WC_Payment_Gateway_Plugin {
42
 
43
 
44
  /** plugin version number */
45
- const VERSION = '2.2.0';
46
 
47
  /** plugin ID */
48
  const PLUGIN_ID = 'square';
42
 
43
 
44
  /** plugin version number */
45
+ const VERSION = '2.2.1';
46
 
47
  /** plugin ID */
48
  const PLUGIN_ID = 'square';
includes/Sync/Product_Import.php CHANGED
@@ -86,10 +86,11 @@ class Product_Import extends Stepped_Job {
86
  */
87
  protected function import_products() {
88
 
89
- $cursor = $this->get_attr( 'fetch_products_cursor' );
90
- $imported_product_ids = $this->get_attr( 'processed_product_ids', array() );
91
- $updated_product_ids = $this->get_attr( 'updated_product_ids', array() );
92
- $skipped_products = $this->get_attr( 'skipped_products', array() );
 
93
 
94
  $response = wc_square()->get_api()->search_catalog_objects(
95
  array(
@@ -144,6 +145,21 @@ class Product_Import extends Stepped_Job {
144
  continue;
145
  }
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  // import or update categories related to the products that are being imported
148
  $catelog_category_id = $catalog_object->getItemData()->getCategoryId();
149
 
@@ -152,14 +168,6 @@ class Product_Import extends Stepped_Job {
152
  unset( $categories[ $catelog_category_id ] ); // don't import/update the same category multiple times per batch
153
  }
154
 
155
- $product_id = Product::get_product_id_by_square_id( $item_id );
156
- $product = ! empty( $product_id ) ? wc_get_product( $product_id ) : null;
157
-
158
- if ( $product_id && ! $product ) {
159
- $this->record_error( 'Product not found', $catalog_object, 'update' );
160
- continue;
161
- }
162
-
163
  $data = $this->extract_product_data( $catalog_object, $product );
164
 
165
  /**
86
  */
87
  protected function import_products() {
88
 
89
+ $cursor = $this->get_attr( 'fetch_products_cursor' );
90
+ $imported_product_ids = $this->get_attr( 'processed_product_ids', array() );
91
+ $updated_product_ids = $this->get_attr( 'updated_product_ids', array() );
92
+ $skipped_products = $this->get_attr( 'skipped_products', array() );
93
+ $update_products_during_import = $this->get_attr( 'update_products_during_import', false );
94
 
95
  $response = wc_square()->get_api()->search_catalog_objects(
96
  array(
145
  continue;
146
  }
147
 
148
+ $product_id = (int) Product::get_product_id_by_square_id( $item_id );
149
+ $product = ! empty( $product_id ) ? wc_get_product( $product_id ) : null;
150
+
151
+ if ( in_array( $product_id, array_merge( $imported_product_ids, $updated_product_ids ), true ) ) {
152
+ continue; // don't import/update the same product twice.
153
+
154
+ } elseif ( $product_id && ! $update_products_during_import ) {
155
+ $skipped_products[ $item_id ] = null;
156
+ continue;
157
+
158
+ } elseif ( $product_id && ! $product ) {
159
+ $this->record_error( 'Product not found', $catalog_object, 'update' );
160
+ continue;
161
+ }
162
+
163
  // import or update categories related to the products that are being imported
164
  $catelog_category_id = $catalog_object->getItemData()->getCategoryId();
165
 
168
  unset( $categories[ $catelog_category_id ] ); // don't import/update the same category multiple times per batch
169
  }
170
 
 
 
 
 
 
 
 
 
171
  $data = $this->extract_product_data( $catalog_object, $product );
172
 
173
  /**
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === WooCommerce Square ===
2
- Contributors: woocommerce, automattic, royho, woothemes, bor0, mattdallan, menakas, chickenn00dle
3
  Tags: credit card, square, woocommerce, inventory sync
4
  Requires at least: 4.6
5
  Tested up to: 5.5
6
  Requires PHP: 5.6
7
- Stable tag: 2.2.0
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -72,6 +72,12 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
72
 
73
  == Changelog ==
74
 
 
 
 
 
 
 
75
  = 2.2.0 - 2020.08.31 =
76
  * Feature - Import new product variations from square to existing products in WooCommerce. PR#475
77
  * Feature - Variations that are removed from Square will now be removed from products in WooCommerce during import. PR#475
1
  === WooCommerce Square ===
2
+ Contributors: woocommerce, automattic, royho, woothemes, bor0, mattdallan, menakas, chickenn00dle, jorgeatorres, jamesgallan
3
  Tags: credit card, square, woocommerce, inventory sync
4
  Requires at least: 4.6
5
  Tested up to: 5.5
6
  Requires PHP: 5.6
7
+ Stable tag: 2.2.1
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
72
 
73
  == Changelog ==
74
 
75
+ = 2.2.1 - 2020.09.11 =
76
+ * New - Make the "Update existing products" part of the new import process optional by adding a new checkbox on Import Products modal. PR#508
77
+ * Fix - Stop the import process from getting stuck in a loop when reaching the time limit. PR#511
78
+ * Fix - Don't import/update categories from Square that are attached to products that cannot be found in WooCommerce. PR#511
79
+ * Fix - "idempotency_key must not be greater than 45 length" errors returned by some payment requests on stores using custom order number plugins. PR#507
80
+
81
  = 2.2.0 - 2020.08.31 =
82
  * Feature - Import new product variations from square to existing products in WooCommerce. PR#475
83
  * Feature - Variations that are removed from Square will now be removed from products in WooCommerce during import. PR#475
woocommerce-square.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
- * Version: 2.2.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
@@ -19,7 +19,7 @@
19
  * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
20
  *
21
  * WC requires at least: 3.0
22
- * WC tested up to: 4.4
23
  */
24
 
25
  defined( 'ABSPATH' ) || exit;
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
+ * Version: 2.2.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
19
  * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
20
  *
21
  * WC requires at least: 3.0
22
+ * WC tested up to: 4.5
23
  */
24
 
25
  defined( 'ABSPATH' ) || exit;