Facebook for WooCommerce - Version 2.0.5

Version Description

Download this release

Release Info

Developer SkyVerge
Plugin Icon Facebook for WooCommerce
Version 2.0.5
Comparing to
See all releases

Code changes from version 2.0.4 to 2.0.5

assets/js/admin/facebook-for-woocommerce-products-admin.js CHANGED
@@ -124,6 +124,27 @@ jQuery( document ).ready( function( $ ) {
124
  }
125
 
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  // toggle Facebook settings fields for simple products
128
  const syncModeSelect = $( '#wc_facebook_sync_mode' );
129
  const facebookSettingsPanel = syncModeSelect.closest( '.woocommerce_options_panel' );
@@ -194,7 +215,7 @@ jQuery( document ).ready( function( $ ) {
194
  // this query will get tags when not using checkboxes
195
  productTag = $( 'textarea[name="tax_input[product_tag]"]' ).length ? $( 'textarea[name="tax_input[product_tag]"]' ).val().split( ',' ) : [],
196
  syncEnabled = $( '#wc_facebook_sync_mode' ).val() !== 'sync_disabled',
197
- varSyncEnabled = $( '.js-variable-fb-sync-toggle' ).val() !== 'sync_disabled';
198
 
199
  $( '#taxonomy-product_cat input[name="tax_input[product_cat][]"]:checked' ).each( function() {
200
  productCat.push( parseInt( $( this ).val(), 10 ) );
124
  }
125
 
126
 
127
+ /**
128
+ * Determines whether the current product has synced variations.
129
+ *
130
+ * @since 2.0.5
131
+ *
132
+ * @returns {boolean}
133
+ */
134
+ function isSyncEnabledForVariableProduct() {
135
+
136
+ let $fields = $( '.js-variable-fb-sync-toggle' );
137
+
138
+ // fallback to the value at page load if the variation fields haven't been loaded
139
+ if ( 0 === $fields.length ) {
140
+ return !! facebook_for_woocommerce_products_admin.is_sync_enabled_for_product;
141
+ }
142
+
143
+ // returns true if any of the Facebook Sync settings is set to a value other than 'sync_disabled'
144
+ return !! $fields.map( ( i, element ) => $( element ).val() !== 'sync_disabled' ? element : null ).length;
145
+ }
146
+
147
+
148
  // toggle Facebook settings fields for simple products
149
  const syncModeSelect = $( '#wc_facebook_sync_mode' );
150
  const facebookSettingsPanel = syncModeSelect.closest( '.woocommerce_options_panel' );
215
  // this query will get tags when not using checkboxes
216
  productTag = $( 'textarea[name="tax_input[product_tag]"]' ).length ? $( 'textarea[name="tax_input[product_tag]"]' ).val().split( ',' ) : [],
217
  syncEnabled = $( '#wc_facebook_sync_mode' ).val() !== 'sync_disabled',
218
+ varSyncEnabled = isSyncEnabledForVariableProduct();
219
 
220
  $( '#taxonomy-product_cat input[name="tax_input[product_cat][]"]:checked' ).each( function() {
221
  productCat.push( parseInt( $( this ).val(), 10 ) );
assets/js/admin/facebook-for-woocommerce-products-admin.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";jQuery(document).ready(function(r){var o=window.pagenow.length?window.pagenow:"";window.typenow.length&&window.typenow;if("edit-product"===o){var a=!1;r("input#doaction, input#doaction2").on("click",function(o){if(a)return!0;o.preventDefault();var e=r(this),c=e.prev("select").val();if("facebook_include"===c){var t=[];r.each(r('input[name="post[]"]:checked'),function(){t.push(parseInt(r(this).val(),10))}),r.post(facebook_for_woocommerce_products_admin.ajax_url,{action:"facebook_for_woocommerce_set_product_sync_bulk_action_prompt",security:facebook_for_woocommerce_products_admin.set_product_sync_bulk_action_prompt_nonce,toggle:c,products:t},function(o){o&&!o.success?(r("#wc-backbone-modal-dialog .modal-close").trigger("click"),new r.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:o.data})):(a=!0,e.trigger("click"))})}else a=!0,e.trigger("click")})}if("product"===o){var e=function(o,e){e.find(".enable-if-sync-enabled").prop("disabled",!o)},c=function(o,e){o?(e.find("option[value='sync_and_show']").show(),e.prop("original")&&e.val(e.prop("original"))):(e.find("option[value='sync_and_show']").hide(),"sync_and_show"===e.val()&&e.val("sync_and_hide"))},t=r("#wc_facebook_sync_mode"),n=t.closest(".woocommerce_options_panel");t.on("change",function(){e("sync_disabled"!==r(this).val(),n),t.prop("original",r(this).val())}).trigger("change"),r("#_virtual").on("change",function(){c(!r(this).prop("checked"),t)}).trigger("change"),r(".woocommerce_variations").on("change",".js-variable-fb-sync-toggle",function(){e("sync_disabled"!==r(this).val(),r(this).closest(".wc-metabox-content")),r(this).prop("original",r(this).val())}),r("#woocommerce-product-data").on("woocommerce_variations_loaded",function(){r(".js-variable-fb-sync-toggle").each(function(){e("sync_disabled"!==r(this).val(),r(this).closest(".wc-metabox-content")),r(this).prop("original",r(this).val())}),r(".variable_is_virtual").on("change",function(){var o=r(this).closest(".wc-metabox-content").find(".js-variable-fb-sync-toggle");c(!r(this).prop("checked"),o)})}),r("#woocommerce-product-data").on("change",".js-fb-product-image-source",function(){var o=r(this).closest(".woocommerce_options_panel, .wc-metabox-content"),e=r(this).val();o.find(".product-image-source-field").closest(".form-field").hide(),o.find(".show-if-product-image-source-"+e).closest(".form-field").show()}),r(".js-fb-product-image-source:checked:visible").trigger("change"),r("#woocommerce-product-data").on("woocommerce_variations_loaded",function(){r(".js-variable-fb-sync-toggle:visible").trigger("change"),r(".js-fb-product-image-source:checked:visible").trigger("change"),r(".variable_is_virtual:visible").trigger("change")});var s=!1;r('form#post input[type="submit"]').on("click",function(o){if(s)return!0;o.preventDefault();var e=r(this),c=parseInt(r("input#post_ID").val(),10),t=[],a=r('textarea[name="tax_input[product_tag]"]').length?r('textarea[name="tax_input[product_tag]"]').val().split(","):[],n="sync_disabled"!==r("#wc_facebook_sync_mode").val(),i="sync_disabled"!==r(".js-variable-fb-sync-toggle").val();r('#taxonomy-product_cat input[name="tax_input[product_cat][]"]:checked').each(function(){t.push(parseInt(r(this).val(),10))}),r('#taxonomy-product_tag input[name="tax_input[product_tag][]"]:checked').each(function(){a.push(parseInt(r(this).val(),10))}),0<c?r.post(facebook_for_woocommerce_products_admin.ajax_url,{action:"facebook_for_woocommerce_set_product_sync_prompt",security:facebook_for_woocommerce_products_admin.set_product_sync_prompt_nonce,sync_enabled:n?"enabled":"disabled",var_sync_enabled:i?"enabled":"disabled",product:c,categories:t,tags:a},function(o){o&&!o.success&&n?(r("#wc-backbone-modal-dialog .modal-close").trigger("click"),new r.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:o.data})):(s=!0,e.trigger("click"))}):(s=!0,e.trigger("click"))})}});
1
+ "use strict";jQuery(document).ready(function(i){var t,o,e,c,a,r,n=window.pagenow.length?window.pagenow:"";window.typenow.length&&window.typenow;"edit-product"===n&&(t=!1,i("input#doaction, input#doaction2").on("click",function(o){if(t)return!0;o.preventDefault();var e,c=i(this),o=c.prev("select").val();"facebook_include"===o?(e=[],i.each(i('input[name="post[]"]:checked'),function(){e.push(parseInt(i(this).val(),10))}),i.post(facebook_for_woocommerce_products_admin.ajax_url,{action:"facebook_for_woocommerce_set_product_sync_bulk_action_prompt",security:facebook_for_woocommerce_products_admin.set_product_sync_bulk_action_prompt_nonce,toggle:o,products:e},function(o){o&&!o.success?(i("#wc-backbone-modal-dialog .modal-close").trigger("click"),new i.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:o.data})):(t=!0,c.trigger("click"))})):(t=!0,c.trigger("click"))})),"product"===n&&(o=function(o,e){e.find(".enable-if-sync-enabled").prop("disabled",!o)},e=function(o,e){o?(e.find("option[value='sync_and_show']").show(),e.prop("original")&&e.val(e.prop("original"))):(e.find("option[value='sync_and_show']").hide(),"sync_and_show"===e.val()&&e.val("sync_and_hide"))},c=i("#wc_facebook_sync_mode"),a=c.closest(".woocommerce_options_panel"),c.on("change",function(){o("sync_disabled"!==i(this).val(),a),c.prop("original",i(this).val())}).trigger("change"),i("#_virtual").on("change",function(){e(!i(this).prop("checked"),c)}).trigger("change"),i(".woocommerce_variations").on("change",".js-variable-fb-sync-toggle",function(){o("sync_disabled"!==i(this).val(),i(this).closest(".wc-metabox-content")),i(this).prop("original",i(this).val())}),i("#woocommerce-product-data").on("woocommerce_variations_loaded",function(){i(".js-variable-fb-sync-toggle").each(function(){o("sync_disabled"!==i(this).val(),i(this).closest(".wc-metabox-content")),i(this).prop("original",i(this).val())}),i(".variable_is_virtual").on("change",function(){var o=i(this).closest(".wc-metabox-content").find(".js-variable-fb-sync-toggle");e(!i(this).prop("checked"),o)})}),i("#woocommerce-product-data").on("change",".js-fb-product-image-source",function(){var o=i(this).closest(".woocommerce_options_panel, .wc-metabox-content"),e=i(this).val();o.find(".product-image-source-field").closest(".form-field").hide(),o.find(".show-if-product-image-source-"+e).closest(".form-field").show()}),i(".js-fb-product-image-source:checked:visible").trigger("change"),i("#woocommerce-product-data").on("woocommerce_variations_loaded",function(){i(".js-variable-fb-sync-toggle:visible").trigger("change"),i(".js-fb-product-image-source:checked:visible").trigger("change"),i(".variable_is_virtual:visible").trigger("change")}),r=!1,i('form#post input[type="submit"]').on("click",function(o){if(r)return!0;o.preventDefault();var e=i(this),c=parseInt(i("input#post_ID").val(),10),t=[],a=i('textarea[name="tax_input[product_tag]"]').length?i('textarea[name="tax_input[product_tag]"]').val().split(","):[],n="sync_disabled"!==i("#wc_facebook_sync_mode").val(),o=0===(o=i(".js-variable-fb-sync-toggle")).length?!!facebook_for_woocommerce_products_admin.is_sync_enabled_for_product:!!o.map(function(o,e){return"sync_disabled"!==i(e).val()?e:null}).length;i('#taxonomy-product_cat input[name="tax_input[product_cat][]"]:checked').each(function(){t.push(parseInt(i(this).val(),10))}),i('#taxonomy-product_tag input[name="tax_input[product_tag][]"]:checked').each(function(){a.push(parseInt(i(this).val(),10))}),0<c?i.post(facebook_for_woocommerce_products_admin.ajax_url,{action:"facebook_for_woocommerce_set_product_sync_prompt",security:facebook_for_woocommerce_products_admin.set_product_sync_prompt_nonce,sync_enabled:n?"enabled":"disabled",var_sync_enabled:o?"enabled":"disabled",product:c,categories:t,tags:a},function(o){o&&!o.success&&n?(i("#wc-backbone-modal-dialog .modal-close").trigger("click"),new i.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:o.data})):(r=!0,e.trigger("click"))}):(r=!0,e.trigger("click"))}))});
assets/js/admin/facebook-for-woocommerce-settings-messenger.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";jQuery(document).ready(function(c){function s(s){c(".messenger-field").each(function(){var e=c(this);c(this).hasClass("wc-enhanced-select")&&(e=c(this).next("span.select2-container")),s?e.css("pointer-events","all").css("opacity","1.0"):e.css("pointer-events","none").css("opacity","0.4")})}c("form.wc-facebook-settings").hasClass("disconnected")&&s(!1),c("input#wc_facebook_enable_messenger").on("change",function(e){c("form.wc-facebook-settings").hasClass("disconnected")?c(this).css("pointer-events","none").css("opacity","0.4"):s(c(this).is(":checked"))}).trigger("change"),c("textarea#wc_facebook_messenger_greeting").on("focus change keyup keydown keypress",function(){var e=parseInt(c(this).attr("maxlength"),10),s=c(this).val().length,n=c("span.characters-counter"),i=n.find("span");n.html(s+" / "+e+"<br/>").append(i).css("display","block"),e<s?n.css("color","#DC3232").find("span").show():n.css("color","#999999").find("span").hide()}),c("#wc_facebook_messenger_color_hex").iris({change:function(e,s){c(this).parent().find(".colorpickpreview").css({backgroundColor:s.color.toString()})},hide:!0,border:!0}).on("click focus",function(e){e.stopPropagation(),c(".iris-picker").hide(),c(this).closest("td").find(".iris-picker").show(),c(this).data("original-value",c(this).val())}).on("change",function(){c(this).is(".iris-error")&&(c(this).data("original-value").match(/^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/)?c(this).val(c(this).data("original-value")).change():c(this).val("").change())}),c("body").on("click",function(){c(".iris-picker").hide()})});
1
+ "use strict";jQuery(document).ready(function(c){function s(s){c(".messenger-field").each(function(){var e=c(this);c(this).hasClass("wc-enhanced-select")&&(e=c(this).next("span.select2-container")),s?e.css("pointer-events","all").css("opacity","1.0"):e.css("pointer-events","none").css("opacity","0.4")})}c("form.wc-facebook-settings").hasClass("disconnected")&&s(!1),c("input#wc_facebook_enable_messenger").on("change",function(e){c("form.wc-facebook-settings").hasClass("disconnected")?c(this).css("pointer-events","none").css("opacity","0.4"):s(c(this).is(":checked"))}).trigger("change"),c("textarea#wc_facebook_messenger_greeting").on("focus change keyup keydown keypress",function(){var e=parseInt(c(this).attr("maxlength"),10),s=c(this).val().length,n=c("span.characters-counter"),i=n.find("span");n.html(s+" / "+e+"<br/>").append(i).css("display","block"),e<s?n.css("color","#DC3232").find("span").show():n.css("color","#999999").find("span").hide()}),c("#wc_facebook_messenger_color_hex").iris({change:function(e,s){c(this).parent().find(".colorpickpreview").css({backgroundColor:s.color.toString()})},hide:!0,border:!0}).on("click focus",function(e){e.stopPropagation(),c(".iris-picker").hide(),c(this).closest("td").find(".iris-picker").show(),c(this).data("original-value",c(this).val())}).on("change",function(){c(this).is(".iris-error")&&(c(this).data("original-value").match(/^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/)?c(this).val(c(this).data("original-value")):c(this).val("")).change()}),c("body").on("click",function(){c(".iris-picker").hide()})});
assets/js/admin/facebook-for-woocommerce-settings-sync.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";jQuery(document).ready(function(a){function n(e){a(".product-sync-field").each(function(){var o=a(this);a(this).hasClass("wc-enhanced-select")&&(o=a(this).next("span.select2-container")),e?o.css("pointer-events","all").css("opacity","1.0"):o.css("pointer-events","none").css("opacity","0.4")})}a(".woocommerce-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),a("form.wc-facebook-settings").hasClass("disconnected")&&n(!1),a("input#wc_facebook_enable_product_sync").on("change",function(o){a("form.wc-facebook-settings").hasClass("disconnected")?a(this).css("pointer-events","none").css("opacity","0.4"):n(a(this).is(":checked"))}).trigger("change");var i=!1;function e(o){s(0<arguments.length&&void 0!==o?o:null),window.syncStatusInterval||(window.syncStatusInterval=setInterval(_,1e4))}function s(o){var e=0<arguments.length&&void 0!==o?o:null;n(!1),a('input#wc_facebook_enable_product_sync, input[name="save_product_sync_settings"]').css("pointer-events","none").css("opacity","0.4");var c=facebook_for_woocommerce_settings_sync.i18n.sync_in_progress;e&&(c=(c+=1<e?facebook_for_woocommerce_settings_sync.i18n.sync_remaining_items_plural:facebook_for_woocommerce_settings_sync.i18n.sync_remaining_items_singular).replace("{count}",e)),a("#sync_progress").show().html(c).css("color","inherit"),facebook_for_woocommerce_settings_sync.sync_in_progress=!0}function t(o){var e=0<arguments.length&&void 0!==o?o:"";facebook_for_woocommerce_settings_sync.sync_in_progress=!1,clearInterval(window.syncStatusInterval),n(!(window.syncStatusInterval=null)),a('input#wc_facebook_enable_product_sync, input[name="save_product_sync_settings"]').css("pointer-events","all").css("opacity","1"),e?a("#sync_progress").show().html(e).css("color","#DC3232"):a("#sync_progress").hide()}function _(){facebook_for_woocommerce_settings_sync.sync_in_progress&&a.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"wc_facebook_get_sync_status",nonce:facebook_for_woocommerce_settings_sync.sync_status_nonce},function(o){console.log(o),o.success&&(0<o.data?e(o.data):t())})}a('input[name="save_product_sync_settings"]').on("click",function(o){if(i)return!0;o.preventDefault();var e,c,n,s,t=a(this),_=(n=a("#wc_facebook_excluded_product_category_ids").val(),s=[],window.facebook_for_woocommerce_settings_sync&&window.facebook_for_woocommerce_settings_sync.excluded_category_ids&&(s=window.facebook_for_woocommerce_settings_sync.excluded_category_ids),a(n).not(s).get()),r=(e=a("#wc_facebook_excluded_product_tag_ids").val(),c=[],window.facebook_for_woocommerce_settings_sync&&window.facebook_for_woocommerce_settings_sync.excluded_tag_ids&&(c=window.facebook_for_woocommerce_settings_sync.excluded_tag_ids),a(e).not(c).get());0<_.length||0<r.length?a.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"facebook_for_woocommerce_set_excluded_terms_prompt",security:facebook_for_woocommerce_settings_sync.set_excluded_terms_prompt_nonce,categories:_,tags:r},function(o){o&&!o.success?(a("#wc-backbone-modal-dialog .modal-close").trigger("click"),new a.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:o.data}),a(".facebook-for-woocommerce-confirm-settings-change").on("click",function(){blockModal(),i=!0,t.trigger("click")})):(i=!0,t.trigger("click"))}):(i=!0,t.trigger("click"))}),facebook_for_woocommerce_settings_sync.sync_in_progress&&e(),a("#woocommerce-facebook-settings-sync-products").click(function(o){if(o.preventDefault(),confirm(facebook_for_woocommerce_settings_sync.i18n.confirm_sync)){s();var c=Date.now();a.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"wc_facebook_sync_products",nonce:facebook_for_woocommerce_settings_sync.sync_products_nonce},function(o){if(console.log(o),o.success)setTimeout(_,Math.max(0,1e4-(Date.now()-c)));else{var e=facebook_for_woocommerce_settings_sync.i18n.general_error;o.data&&0<o.data.length&&(e=o.data),t(e)}}).fail(function(){t(facebook_for_woocommerce_settings_sync.i18n.general_error)})}})});
1
+ "use strict";jQuery(document).ready(function(s){function c(e){s(".product-sync-field").each(function(){var o=s(this);s(this).hasClass("wc-enhanced-select")&&(o=s(this).next("span.select2-container")),e?o.css("pointer-events","all").css("opacity","1.0"):o.css("pointer-events","none").css("opacity","0.4")})}s(".woocommerce-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),s("form.wc-facebook-settings").hasClass("disconnected")&&c(!1),s("input#wc_facebook_enable_product_sync").on("change",function(o){s("form.wc-facebook-settings").hasClass("disconnected")?s(this).css("pointer-events","none").css("opacity","0.4"):c(s(this).is(":checked"))}).trigger("change");var t=!1;function e(o){n(0<arguments.length&&void 0!==o?o:null),window.syncStatusInterval||(window.syncStatusInterval=setInterval(r,1e4))}function n(o){var e=0<arguments.length&&void 0!==o?o:null;c(!1),s('input#wc_facebook_enable_product_sync, input[name="save_product_sync_settings"]').css("pointer-events","none").css("opacity","0.4");o=facebook_for_woocommerce_settings_sync.i18n.sync_in_progress;e&&(o=(o+=1<e?facebook_for_woocommerce_settings_sync.i18n.sync_remaining_items_plural:facebook_for_woocommerce_settings_sync.i18n.sync_remaining_items_singular).replace("{count}",e)),s("#sync_progress").show().html(o).css("color","inherit"),facebook_for_woocommerce_settings_sync.sync_in_progress=!0}function _(o){o=0<arguments.length&&void 0!==o?o:"";facebook_for_woocommerce_settings_sync.sync_in_progress=!1,clearInterval(window.syncStatusInterval),c(!(window.syncStatusInterval=null)),s('input#wc_facebook_enable_product_sync, input[name="save_product_sync_settings"]').css("pointer-events","all").css("opacity","1"),o?s("#sync_progress").show().html(o).css("color","#DC3232"):s("#sync_progress").hide()}function r(){facebook_for_woocommerce_settings_sync.sync_in_progress&&s.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"wc_facebook_get_sync_status",nonce:facebook_for_woocommerce_settings_sync.sync_status_nonce},function(o){console.log(o),o.success&&(0<o.data?e(o.data):_())})}s('input[name="save_product_sync_settings"]').on("click",function(o){if(t)return!0;o.preventDefault();var e,c,n=s(this),o=(e=s("#wc_facebook_excluded_product_category_ids").val(),c=[],window.facebook_for_woocommerce_settings_sync&&window.facebook_for_woocommerce_settings_sync.excluded_category_ids&&(c=window.facebook_for_woocommerce_settings_sync.excluded_category_ids),s(e).not(c).get()),c=(e=s("#wc_facebook_excluded_product_tag_ids").val(),c=[],window.facebook_for_woocommerce_settings_sync&&window.facebook_for_woocommerce_settings_sync.excluded_tag_ids&&(c=window.facebook_for_woocommerce_settings_sync.excluded_tag_ids),s(e).not(c).get());0<o.length||0<c.length?s.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"facebook_for_woocommerce_set_excluded_terms_prompt",security:facebook_for_woocommerce_settings_sync.set_excluded_terms_prompt_nonce,categories:o,tags:c},function(o){o&&!o.success?(s("#wc-backbone-modal-dialog .modal-close").trigger("click"),new s.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:o.data}),s(".facebook-for-woocommerce-confirm-settings-change").on("click",function(){blockModal(),t=!0,n.trigger("click")})):(t=!0,n.trigger("click"))}):(t=!0,n.trigger("click"))}),facebook_for_woocommerce_settings_sync.sync_in_progress&&e(),s("#woocommerce-facebook-settings-sync-products").click(function(o){var c;o.preventDefault(),confirm(facebook_for_woocommerce_settings_sync.i18n.confirm_sync)&&(n(),c=Date.now(),s.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"wc_facebook_sync_products",nonce:facebook_for_woocommerce_settings_sync.sync_products_nonce},function(o){var e;console.log(o),o.success?setTimeout(r,Math.max(0,1e4-(Date.now()-c))):(e=facebook_for_woocommerce_settings_sync.i18n.general_error,o.data&&0<o.data.length&&(e=o.data),_(e))}).fail(function(){_(facebook_for_woocommerce_settings_sync.i18n.general_error)}))})});
assets/js/facebook-infobanner.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";function ajax(n){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,t=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,_=Object.assign({},{action:n},o);jQuery.post(ajaxurl,_,function(n){a&&a(n)}).fail(function(n){t&&t(n)})}function fb_woo_infobanner_post_click(){return console.log("Woo infobanner post tip click!"),ajax("ajax_woo_infobanner_post_click",{_ajax_nonce:wc_facebook_infobanner_jsx.nonce})}function fb_woo_infobanner_post_xout(){return console.log("Woo infobanner post tip xout!"),ajax("ajax_woo_infobanner_post_xout",{_ajax_nonce:wc_facebook_infobanner_jsx.nonce})}
1
+ "use strict";function ajax(n){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,t=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,o=Object.assign({},{action:n},o);jQuery.post(ajaxurl,o,function(n){a&&a(n)}).fail(function(n){t&&t(n)})}function fb_woo_infobanner_post_click(){return console.log("Woo infobanner post tip click!"),ajax("ajax_woo_infobanner_post_click",{_ajax_nonce:wc_facebook_infobanner_jsx.nonce})}function fb_woo_infobanner_post_xout(){return console.log("Woo infobanner post tip xout!"),ajax("ajax_woo_infobanner_post_xout",{_ajax_nonce:wc_facebook_infobanner_jsx.nonce})}
assets/js/facebook-metabox.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";function ajax(e){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,n=Object.assign({},{action:e},o);jQuery.post(ajaxurl,n,function(e){t&&t(e)}).fail(function(e){a&&a(e)})}function fb_reset_product(e){if(confirm("Resetting Facebook metadata will not remove this product from your shop. If you have duplicated another product and are trying to publish a new Facebook product, click OK to proceed. Otherwise, Facebook metadata will be restored when this product is updated again.")){var o=document.querySelector("#fb_metadata");return o&&(o.innerHTML="<b>This product is not yet synced to Facebook.</b>"),ajax("ajax_reset_single_fb_product",{wp_id:e,_ajax_nonce:wc_facebook_metabox_jsx.nonce})}}function fb_delete_product(e){if(confirm('Are you sure you want to delete this product on Facebook? If you only want to "hide" the product, change the "Facebook sync" setting to "Sync and hide" and hit "Update". If you delete a product on Facebook and hit "Update" after, this product will be recreated. To permanently remove this product from Facebook, hit "OK" and close the window.This will not delete the product from WooCommerce.')){var o=document.querySelector("#fb_metadata");return o&&(o.innerHTML="<b>This product is not yet synced to Facebook.</b>"),ajax("ajax_delete_fb_product",{wp_id:e,_ajax_nonce:wc_facebook_metabox_jsx.nonce})}}
1
+ "use strict";function ajax(e){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,o=Object.assign({},{action:e},o);jQuery.post(ajaxurl,o,function(e){t&&t(e)}).fail(function(e){a&&a(e)})}function fb_reset_product(e){if(confirm("Resetting Facebook metadata will not remove this product from your shop. If you have duplicated another product and are trying to publish a new Facebook product, click OK to proceed. Otherwise, Facebook metadata will be restored when this product is updated again.")){var o=document.querySelector("#fb_metadata");return o&&(o.innerHTML="<b>This product is not yet synced to Facebook.</b>"),ajax("ajax_reset_single_fb_product",{wp_id:e,_ajax_nonce:wc_facebook_metabox_jsx.nonce})}}function fb_delete_product(e){if(confirm('Are you sure you want to delete this product on Facebook? If you only want to "hide" the product, change the "Facebook sync" setting to "Sync and hide" and hit "Update". If you delete a product on Facebook and hit "Update" after, this product will be recreated. To permanently remove this product from Facebook, hit "OK" and close the window.This will not delete the product from WooCommerce.')){var o=document.querySelector("#fb_metadata");return o&&(o.innerHTML="<b>This product is not yet synced to Facebook.</b>"),ajax("ajax_delete_fb_product",{wp_id:e,_ajax_nonce:wc_facebook_metabox_jsx.nonce})}}
changelog.txt CHANGED
@@ -1,5 +1,10 @@
1
  *** Facebook for WooCommerce Changelog ***
2
 
 
 
 
 
 
3
  2020.10.08 - version 2.0.4
4
  * Fix - Fix SQL errors triggered while trying to remove duplicate visibility meta entries from postmeta table
5
 
1
  *** Facebook for WooCommerce Changelog ***
2
 
3
+ 2020.10.12 - version 2.0.5
4
+ * Tweak - Update product availability when stock changes in the store
5
+ * Fix - Don't prevent variation products from being updated when they're set to not sync with Facebook but have their categories excluded from syncing
6
+ * Fix - Prevent an error during the feed generation when variable products are still using deleted terms
7
+
8
  2020.10.08 - version 2.0.4
9
  * Fix - Fix SQL errors triggered while trying to remove duplicate visibility meta entries from postmeta table
10
 
class-wc-facebookcommerce.php CHANGED
@@ -22,7 +22,7 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
22
 
23
 
24
  /** @var string the plugin version */
25
- const VERSION = '2.0.4';
26
 
27
  /** @var string for backwards compatibility TODO: remove this in v2.0.0 {CW 2020-02-06} */
28
  const PLUGIN_VERSION = self::VERSION;
@@ -61,6 +61,9 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
61
  /** @var Background_Remove_Duplicate_Visibility_Meta job handler instance */
62
  protected $background_remove_duplicate_visibility_meta;
63
 
 
 
 
64
  /** @var \SkyVerge\WooCommerce\Facebook\Products\Sync products sync handler */
65
  private $products_sync_handler;
66
 
@@ -113,6 +116,7 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
113
  require_once __DIR__ . '/includes/Integrations/Integrations.php';
114
  require_once __DIR__ . '/includes/Products.php';
115
  require_once __DIR__ . '/includes/Products/Feed.php';
 
116
  require_once __DIR__ . '/includes/Products/Sync.php';
117
  require_once __DIR__ . '/includes/Products/Sync/Background.php';
118
  require_once __DIR__ . '/includes/fbproductfeed.php';
@@ -122,6 +126,7 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
122
  require_once __DIR__ . '/includes/Events/AAMSettings.php';
123
 
124
  $this->product_feed = new \SkyVerge\WooCommerce\Facebook\Products\Feed();
 
125
  $this->products_sync_handler = new \SkyVerge\WooCommerce\Facebook\Products\Sync();
126
  $this->sync_background_handler = new \SkyVerge\WooCommerce\Facebook\Products\Sync\Background();
127
 
@@ -525,6 +530,19 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
525
  }
526
 
527
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  /**
529
  * Gets the products sync handler.
530
  *
22
 
23
 
24
  /** @var string the plugin version */
25
+ const VERSION = '2.0.5';
26
 
27
  /** @var string for backwards compatibility TODO: remove this in v2.0.0 {CW 2020-02-06} */
28
  const PLUGIN_VERSION = self::VERSION;
61
  /** @var Background_Remove_Duplicate_Visibility_Meta job handler instance */
62
  protected $background_remove_duplicate_visibility_meta;
63
 
64
+ /** @var \SkyVerge\WooCommerce\Facebook\Products\Stock products stock handler */
65
+ private $products_stock_handler;
66
+
67
  /** @var \SkyVerge\WooCommerce\Facebook\Products\Sync products sync handler */
68
  private $products_sync_handler;
69
 
116
  require_once __DIR__ . '/includes/Integrations/Integrations.php';
117
  require_once __DIR__ . '/includes/Products.php';
118
  require_once __DIR__ . '/includes/Products/Feed.php';
119
+ require_once __DIR__ . '/includes/Products/Stock.php';
120
  require_once __DIR__ . '/includes/Products/Sync.php';
121
  require_once __DIR__ . '/includes/Products/Sync/Background.php';
122
  require_once __DIR__ . '/includes/fbproductfeed.php';
126
  require_once __DIR__ . '/includes/Events/AAMSettings.php';
127
 
128
  $this->product_feed = new \SkyVerge\WooCommerce\Facebook\Products\Feed();
129
+ $this->products_stock_handler = new \SkyVerge\WooCommerce\Facebook\Products\Stock();
130
  $this->products_sync_handler = new \SkyVerge\WooCommerce\Facebook\Products\Sync();
131
  $this->sync_background_handler = new \SkyVerge\WooCommerce\Facebook\Products\Sync\Background();
132
 
530
  }
531
 
532
 
533
+ /**
534
+ * Gets the products stock handler.
535
+ *
536
+ * @since 2.0.5
537
+ *
538
+ * @return \SkyVerge\WooCommerce\Facebook\Products\Stock
539
+ */
540
+ public function get_products_stock_handler() {
541
+
542
+ return $this->products_stock_handler;
543
+ }
544
+
545
+
546
  /**
547
  * Gets the products sync handler.
548
  *
facebook-for-woocommerce.php CHANGED
@@ -10,7 +10,7 @@
10
  * Description: Grow your business on Facebook! Use this official plugin to help sell more of your products using Facebook. After completing the setup, you'll be ready to create ads that promote your products and you can also create a shop section on your Page where customers can browse your products on Facebook.
11
  * Author: Facebook
12
  * Author URI: https://www.facebook.com/
13
- * Version: 2.0.4
14
  * Text Domain: facebook-for-woocommerce
15
  * WC requires at least: 3.5.0
16
  * WC tested up to: 4.5.2
10
  * Description: Grow your business on Facebook! Use this official plugin to help sell more of your products using Facebook. After completing the setup, you'll be ready to create ads that promote your products and you can also create a shop section on your Page where customers can browse your products on Facebook.
11
  * Author: Facebook
12
  * Author URI: https://www.facebook.com/
13
+ * Version: 2.0.5
14
  * Text Domain: facebook-for-woocommerce
15
  * WC requires at least: 3.5.0
16
  * WC tested up to: 4.5.2
i18n/languages/facebook-for-woocommerce.pot CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the same license as the Facebook for WooCommerce package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Facebook for WooCommerce 2.0.4\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
- "POT-Creation-Date: 2020-10-08 19:31:07+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -13,7 +13,7 @@ msgstr ""
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
16
- #: class-wc-facebookcommerce.php:201
17
  #. translators: Placeholders %1$s - opening strong HTML tag, %2$s - closing
18
  #. strong HTML tag, %3$s - opening link HTML tag, %4$s - closing link HTML tag
19
  msgid ""
@@ -21,7 +21,7 @@ msgid ""
21
  "Facebook for WooCommerce connection. Please %3$sclick here%4$s to reconnect!"
22
  msgstr ""
23
 
24
- #: class-wc-facebookcommerce.php:216
25
  #. translators: Placeholders %1$s - opening link HTML tag, %2$s - closing link
26
  #. HTML tag
27
  msgid ""
@@ -29,7 +29,7 @@ msgid ""
29
  "under %1$sWooCommerce > Facebook%2$s."
30
  msgstr ""
31
 
32
- #: class-wc-facebookcommerce.php:231
33
  #. translators: Placeholders %1$s - opening strong HTML tag, %2$s - closing
34
  #. strong HTML tag, %3$s - opening link HTML tag, %4$s - closing link HTML tag
35
  msgid ""
@@ -37,7 +37,7 @@ msgid ""
37
  "configuration, %3$scomplete the setup steps%4$s."
38
  msgstr ""
39
 
40
- #: class-wc-facebookcommerce.php:259
41
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
42
  #. <a> tag, %4$s - </a> tag
43
  msgid ""
@@ -46,7 +46,7 @@ msgid ""
46
  "Connection%4$s area."
47
  msgstr ""
48
 
49
- #: class-wc-facebookcommerce.php:276
50
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
51
  #. <a> tag, %4$s - </a> tag
52
  msgid ""
@@ -55,7 +55,7 @@ msgid ""
55
  "products."
56
  msgstr ""
57
 
58
- #: class-wc-facebookcommerce.php:329
59
  msgid "Cannot create the API instance because the access token is missing."
60
  msgstr ""
61
 
@@ -452,36 +452,36 @@ msgstr ""
452
  msgid "Please %1$sconnect to Facebook%2$s to enable and manage product sync."
453
  msgstr ""
454
 
455
- #: includes/Admin.php:147 includes/Admin.php:971 includes/Admin.php:1076
456
  msgid "Facebook sync"
457
  msgstr ""
458
 
459
- #: includes/Admin.php:174 includes/Admin.php:206
460
  msgid "Sync and show"
461
  msgstr ""
462
 
463
- #: includes/Admin.php:176 includes/Admin.php:207
464
  msgid "Sync and hide"
465
  msgstr ""
466
 
467
- #: includes/Admin.php:181 includes/Admin.php:208 includes/Admin.php:975
468
- #: includes/Admin.php:1080
469
  msgid "Do not sync"
470
  msgstr ""
471
 
472
- #: includes/Admin.php:205
473
  msgid "Filter by Facebook sync setting"
474
  msgstr ""
475
 
476
- #: includes/Admin.php:606
477
  msgid "Include in Facebook sync"
478
  msgstr ""
479
 
480
- #: includes/Admin.php:607
481
  msgid "Exclude from Facebook sync"
482
  msgstr ""
483
 
484
- #: includes/Admin.php:800
485
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
486
  #. <a> tag, %4$s - <a> tag
487
  msgid ""
@@ -495,11 +495,11 @@ msgid_plural ""
495
  msgstr[0] ""
496
  msgstr[1] ""
497
 
498
- #: includes/Admin.php:805
499
  msgid "Don't show this notice again"
500
  msgstr ""
501
 
502
- #: includes/Admin.php:837
503
  #. translators: Placeholders: %1$s - number of affected products, %2$s opening
504
  #. HTML <a> tag, %3$s - closing HTML </a> tag, %4$s - opening HTML <a> tag,
505
  #. %5$s - closing HTML </a> tag
@@ -516,7 +516,7 @@ msgid_plural ""
516
  msgstr[0] ""
517
  msgstr[1] ""
518
 
519
- #: includes/Admin.php:900
520
  #. translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing
521
  #. HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a>
522
  #. tag
@@ -526,69 +526,69 @@ msgid ""
526
  "your Facebook catalog. You may still advertise Virtual products on Facebook."
527
  msgstr ""
528
 
529
- #: includes/Admin.php:973 includes/Admin.php:1078
530
  msgid "Sync and show in catalog"
531
  msgstr ""
532
 
533
- #: includes/Admin.php:974 includes/Admin.php:1079
534
  msgid "Sync and hide in catalog"
535
  msgstr ""
536
 
537
- #: includes/Admin.php:982 includes/Admin.php:1090
538
  msgid "Facebook Description"
539
  msgstr ""
540
 
541
- #: includes/Admin.php:984 includes/Admin.php:1092
542
  msgid ""
543
  "Custom (plain-text only) description for product on Facebook. If blank, "
544
  "product description will be used. If product description is blank, "
545
  "shortname will be used."
546
  msgstr ""
547
 
548
- #: includes/Admin.php:993 includes/Admin.php:1103
549
  msgid "Facebook Product Image"
550
  msgstr ""
551
 
552
- #: includes/Admin.php:995 includes/Admin.php:1105
553
  msgid ""
554
  "Choose the product image that should be synced to the Facebook catalog for "
555
  "this product. If using a custom image, please enter an absolute URL (e.g. "
556
  "https://domain.com/image.jpg)."
557
  msgstr ""
558
 
559
- #: includes/Admin.php:997
560
  msgid "Use WooCommerce image"
561
  msgstr ""
562
 
563
- #: includes/Admin.php:998 includes/Admin.php:1109
564
  msgid "Use custom image"
565
  msgstr ""
566
 
567
- #: includes/Admin.php:1007 includes/Admin.php:1119
568
  msgid "Custom Image URL"
569
  msgstr ""
570
 
571
- #: includes/Admin.php:1016 includes/Admin.php:1130
572
  #. translators: Placeholders %1$s - WC currency symbol
573
  msgid "Facebook Price (%1$s)"
574
  msgstr ""
575
 
576
- #: includes/Admin.php:1020 includes/Admin.php:1134
577
  msgid ""
578
  "Custom price for product on Facebook. Please enter in monetary decimal (.) "
579
  "format without thousand separators and currency symbols. If blank, product "
580
  "price will be used."
581
  msgstr ""
582
 
583
- #: includes/Admin.php:1107
584
  msgid "Use variation image"
585
  msgstr ""
586
 
587
- #: includes/Admin.php:1108
588
  msgid "Use parent image"
589
  msgstr ""
590
 
591
- #: includes/Admin.php:1248
592
  msgid "Close modal panel"
593
  msgstr ""
594
 
2
  # This file is distributed under the same license as the Facebook for WooCommerce package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Facebook for WooCommerce 2.0.5\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
+ "POT-Creation-Date: 2020-10-12 22:40:06+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
16
+ #: class-wc-facebookcommerce.php:206
17
  #. translators: Placeholders %1$s - opening strong HTML tag, %2$s - closing
18
  #. strong HTML tag, %3$s - opening link HTML tag, %4$s - closing link HTML tag
19
  msgid ""
21
  "Facebook for WooCommerce connection. Please %3$sclick here%4$s to reconnect!"
22
  msgstr ""
23
 
24
+ #: class-wc-facebookcommerce.php:221
25
  #. translators: Placeholders %1$s - opening link HTML tag, %2$s - closing link
26
  #. HTML tag
27
  msgid ""
29
  "under %1$sWooCommerce > Facebook%2$s."
30
  msgstr ""
31
 
32
+ #: class-wc-facebookcommerce.php:236
33
  #. translators: Placeholders %1$s - opening strong HTML tag, %2$s - closing
34
  #. strong HTML tag, %3$s - opening link HTML tag, %4$s - closing link HTML tag
35
  msgid ""
37
  "configuration, %3$scomplete the setup steps%4$s."
38
  msgstr ""
39
 
40
+ #: class-wc-facebookcommerce.php:264
41
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
42
  #. <a> tag, %4$s - </a> tag
43
  msgid ""
46
  "Connection%4$s area."
47
  msgstr ""
48
 
49
+ #: class-wc-facebookcommerce.php:281
50
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
51
  #. <a> tag, %4$s - </a> tag
52
  msgid ""
55
  "products."
56
  msgstr ""
57
 
58
+ #: class-wc-facebookcommerce.php:334
59
  msgid "Cannot create the API instance because the access token is missing."
60
  msgstr ""
61
 
452
  msgid "Please %1$sconnect to Facebook%2$s to enable and manage product sync."
453
  msgstr ""
454
 
455
+ #: includes/Admin.php:148 includes/Admin.php:972 includes/Admin.php:1077
456
  msgid "Facebook sync"
457
  msgstr ""
458
 
459
+ #: includes/Admin.php:175 includes/Admin.php:207
460
  msgid "Sync and show"
461
  msgstr ""
462
 
463
+ #: includes/Admin.php:177 includes/Admin.php:208
464
  msgid "Sync and hide"
465
  msgstr ""
466
 
467
+ #: includes/Admin.php:182 includes/Admin.php:209 includes/Admin.php:976
468
+ #: includes/Admin.php:1081
469
  msgid "Do not sync"
470
  msgstr ""
471
 
472
+ #: includes/Admin.php:206
473
  msgid "Filter by Facebook sync setting"
474
  msgstr ""
475
 
476
+ #: includes/Admin.php:607
477
  msgid "Include in Facebook sync"
478
  msgstr ""
479
 
480
+ #: includes/Admin.php:608
481
  msgid "Exclude from Facebook sync"
482
  msgstr ""
483
 
484
+ #: includes/Admin.php:801
485
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
486
  #. <a> tag, %4$s - <a> tag
487
  msgid ""
495
  msgstr[0] ""
496
  msgstr[1] ""
497
 
498
+ #: includes/Admin.php:806
499
  msgid "Don't show this notice again"
500
  msgstr ""
501
 
502
+ #: includes/Admin.php:838
503
  #. translators: Placeholders: %1$s - number of affected products, %2$s opening
504
  #. HTML <a> tag, %3$s - closing HTML </a> tag, %4$s - opening HTML <a> tag,
505
  #. %5$s - closing HTML </a> tag
516
  msgstr[0] ""
517
  msgstr[1] ""
518
 
519
+ #: includes/Admin.php:901
520
  #. translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing
521
  #. HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a>
522
  #. tag
526
  "your Facebook catalog. You may still advertise Virtual products on Facebook."
527
  msgstr ""
528
 
529
+ #: includes/Admin.php:974 includes/Admin.php:1079
530
  msgid "Sync and show in catalog"
531
  msgstr ""
532
 
533
+ #: includes/Admin.php:975 includes/Admin.php:1080
534
  msgid "Sync and hide in catalog"
535
  msgstr ""
536
 
537
+ #: includes/Admin.php:983 includes/Admin.php:1091
538
  msgid "Facebook Description"
539
  msgstr ""
540
 
541
+ #: includes/Admin.php:985 includes/Admin.php:1093
542
  msgid ""
543
  "Custom (plain-text only) description for product on Facebook. If blank, "
544
  "product description will be used. If product description is blank, "
545
  "shortname will be used."
546
  msgstr ""
547
 
548
+ #: includes/Admin.php:994 includes/Admin.php:1104
549
  msgid "Facebook Product Image"
550
  msgstr ""
551
 
552
+ #: includes/Admin.php:996 includes/Admin.php:1106
553
  msgid ""
554
  "Choose the product image that should be synced to the Facebook catalog for "
555
  "this product. If using a custom image, please enter an absolute URL (e.g. "
556
  "https://domain.com/image.jpg)."
557
  msgstr ""
558
 
559
+ #: includes/Admin.php:998
560
  msgid "Use WooCommerce image"
561
  msgstr ""
562
 
563
+ #: includes/Admin.php:999 includes/Admin.php:1110
564
  msgid "Use custom image"
565
  msgstr ""
566
 
567
+ #: includes/Admin.php:1008 includes/Admin.php:1120
568
  msgid "Custom Image URL"
569
  msgstr ""
570
 
571
+ #: includes/Admin.php:1017 includes/Admin.php:1131
572
  #. translators: Placeholders %1$s - WC currency symbol
573
  msgid "Facebook Price (%1$s)"
574
  msgstr ""
575
 
576
+ #: includes/Admin.php:1021 includes/Admin.php:1135
577
  msgid ""
578
  "Custom price for product on Facebook. Please enter in monetary decimal (.) "
579
  "format without thousand separators and currency symbols. If blank, product "
580
  "price will be used."
581
  msgstr ""
582
 
583
+ #: includes/Admin.php:1108
584
  msgid "Use variation image"
585
  msgstr ""
586
 
587
+ #: includes/Admin.php:1109
588
  msgid "Use parent image"
589
  msgstr ""
590
 
591
+ #: includes/Admin.php:1249
592
  msgid "Close modal panel"
593
  msgstr ""
594
 
includes/Admin.php CHANGED
@@ -117,6 +117,7 @@ class Admin {
117
 
118
  wp_localize_script( 'facebook-for-woocommerce-products-admin', 'facebook_for_woocommerce_products_admin', [
119
  'ajax_url' => admin_url( 'admin-ajax.php' ),
 
120
  'set_product_visibility_nonce' => wp_create_nonce( 'set-products-visibility' ),
121
  'set_product_sync_prompt_nonce' => wp_create_nonce( 'set-product-sync-prompt' ),
122
  'set_product_sync_bulk_action_prompt_nonce' => wp_create_nonce( 'set-product-sync-bulk-action-prompt' ),
@@ -1371,4 +1372,24 @@ class Admin {
1371
  }
1372
 
1373
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1374
  }
117
 
118
  wp_localize_script( 'facebook-for-woocommerce-products-admin', 'facebook_for_woocommerce_products_admin', [
119
  'ajax_url' => admin_url( 'admin-ajax.php' ),
120
+ 'is_sync_enabled_for_product' => $this->is_sync_enabled_for_current_product(),
121
  'set_product_visibility_nonce' => wp_create_nonce( 'set-products-visibility' ),
122
  'set_product_sync_prompt_nonce' => wp_create_nonce( 'set-product-sync-prompt' ),
123
  'set_product_sync_bulk_action_prompt_nonce' => wp_create_nonce( 'set-product-sync-bulk-action-prompt' ),
1372
  }
1373
 
1374
 
1375
+ /**
1376
+ * Determines whether sync is enabled for the current product.
1377
+ *
1378
+ * @since 2.0.5
1379
+ *
1380
+ * @return bool
1381
+ */
1382
+ private function is_sync_enabled_for_current_product() {
1383
+ global $post;
1384
+
1385
+ $product = wc_get_product( $post );
1386
+
1387
+ if ( ! $product instanceof \WC_Product ) {
1388
+ return false;
1389
+ }
1390
+
1391
+ return Products::is_sync_enabled_for_product( $product );
1392
+ }
1393
+
1394
+
1395
  }
includes/Products/Stock.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @package FacebookCommerce
9
+ */
10
+
11
+ namespace SkyVerge\WooCommerce\Facebook\Products;
12
+
13
+ defined( 'ABSPATH' ) or exit;
14
+
15
+ use SkyVerge\WooCommerce\Facebook\Products;
16
+
17
+ /**
18
+ * The product stock handler.
19
+ *
20
+ * @since 2.0.5
21
+ */
22
+ class Stock {
23
+
24
+
25
+ /**
26
+ * Stock constructor.
27
+ *
28
+ * @since 2.0.5
29
+ */
30
+ public function __construct() {
31
+
32
+ $this->add_hooks();
33
+ }
34
+
35
+
36
+ /**
37
+ * Adds needed hooks to keep product stock in sync.
38
+ *
39
+ * @since 2.0.5
40
+ */
41
+ private function add_hooks() {
42
+
43
+ add_action( 'woocommerce_variation_set_stock', [ $this, 'set_product_stock' ] );
44
+ add_action( 'woocommerce_product_set_stock', [ $this, 'set_product_stock' ] );
45
+ }
46
+
47
+
48
+ /**
49
+ * Attempts to sync a product when its stock changes.
50
+ *
51
+ * @internal
52
+ *
53
+ * @since 2.0.5
54
+ *
55
+ * @param \WC_Product $product the product that was updated
56
+ */
57
+ public function set_product_stock( $product ) {
58
+
59
+ if ( ! $product instanceof \WC_Product ) {
60
+ return;
61
+ }
62
+
63
+ foreach ( $this->get_products_to_sync( $product ) as $item ) {
64
+ $this->maybe_sync_product_stock_status( $item );
65
+ }
66
+ }
67
+
68
+
69
+ /**
70
+ * Gets an array of product objects that could be synced using the Batch API.
71
+ *
72
+ * This method returns the product variations of variable products, or the product itself for other product types.
73
+ * Variable products cannot be synced through the Batch API as they are represented as Product Groups instead of Product Items on Facebook.
74
+ *
75
+ * @since 2.0.5
76
+ *
77
+ * @param \WC_Product $product a product object
78
+ * @return \WC_Product[]
79
+ */
80
+ private function get_products_to_sync( \WC_Product $product ) {
81
+
82
+ if ( $product->is_type( 'variable' ) ) {
83
+
84
+ return array_filter( array_map( 'wc_get_product', $product->get_children() ), function ( $item ) {
85
+ return $item instanceof \WC_Product;
86
+ } );
87
+ }
88
+
89
+ return [ $product ];
90
+ }
91
+
92
+
93
+ /**
94
+ * Schedules a product sync to update the product's stock status.
95
+ *
96
+ * The product is removed from Facebook if it is out of stock and the plugin is configured to remove out of stock products from the catalog.
97
+ *
98
+ * @since 2.0.5
99
+ *
100
+ * @param \WC_Product $product a product object
101
+ */
102
+ private function maybe_sync_product_stock_status( \WC_Product $product ) {
103
+
104
+ if ( Products::product_should_be_deleted( $product ) ) {
105
+
106
+ facebook_for_woocommerce()->get_products_sync_handler()->delete_products( [ \WC_Facebookcommerce_Utils::get_fb_retailer_id( $product ) ] );
107
+ return;
108
+ }
109
+
110
+ facebook_for_woocommerce()->get_products_sync_handler()->create_or_update_products( [ $product->get_id() ] );
111
+ }
112
+
113
+
114
+ }
includes/fbproduct.php CHANGED
@@ -400,7 +400,7 @@ if ( ! class_exists( 'WC_Facebook_Product' ) ) :
400
  // Convert all slug_names in $option_values into the visible names that
401
  // advertisers have set to be the display names for a given attribute value
402
  $terms = get_the_terms( $this->id, $key );
403
- return array_map(
404
  function ( $slug_name ) use ( $terms ) {
405
  foreach ( $terms as $term ) {
406
  if ( $term->slug === $slug_name ) {
400
  // Convert all slug_names in $option_values into the visible names that
401
  // advertisers have set to be the display names for a given attribute value
402
  $terms = get_the_terms( $this->id, $key );
403
+ return ! is_array( $terms ) ? [] : array_map(
404
  function ( $slug_name ) use ( $terms ) {
405
  foreach ( $terms as $term ) {
406
  if ( $term->slug === $slug_name ) {
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: facebook, automattic, woothemes
3
  Tags: facebook, shop, catalog, advertise, pixel, product
4
  Requires at least: 4.4
5
  Tested up to: 5.5.1
6
- Stable tag: 2.0.4
7
  Requires PHP: 5.6 or greater
8
  MySQL: 5.6 or greater
9
  License: GPLv2 or later
@@ -39,6 +39,11 @@ When opening a bug on GitHub, please give us as many details as possible.
39
 
40
  == Changelog ==
41
 
 
 
 
 
 
42
  = 2020.10.08 - version 2.0.4 =
43
  * Fix - Fix SQL errors triggered while trying to remove duplicate visibility meta entries from postmeta table
44
 
3
  Tags: facebook, shop, catalog, advertise, pixel, product
4
  Requires at least: 4.4
5
  Tested up to: 5.5.1
6
+ Stable tag: 2.0.5
7
  Requires PHP: 5.6 or greater
8
  MySQL: 5.6 or greater
9
  License: GPLv2 or later
39
 
40
  == Changelog ==
41
 
42
+ = 2020.10.12 - version 2.0.5 =
43
+ * Tweak - Update product availability when stock changes in the store
44
+ * Fix - Don't prevent variation products from being updated when they're set to not sync with Facebook but have their categories excluded from syncing
45
+ * Fix - Prevent an error during the feed generation when variable products are still using deleted terms
46
+
47
  = 2020.10.08 - version 2.0.4 =
48
  * Fix - Fix SQL errors triggered while trying to remove duplicate visibility meta entries from postmeta table
49