Facebook for WooCommerce - Version 1.11.3

Version Description

Download this release

Release Info

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

Code changes from version 1.11.2 to 1.11.3

assets/js/admin/facebook-for-woocommerce-products-admin.js CHANGED
@@ -168,6 +168,13 @@ jQuery( document ).ready( function( $ ) {
168
  toggleFacebookSettings( $( this ).prop( 'checked' ), $( this ).closest( '.wc-metabox-content' ) );
169
  } );
170
 
 
 
 
 
 
 
 
171
  // show/hide Custom Image URL setting
172
  $( '#woocommerce-product-data' ).on( 'change', '.js-fb-product-image-source', function() {
173
 
@@ -182,8 +189,8 @@ jQuery( document ).ready( function( $ ) {
182
 
183
  // trigger settings fields modifiers when variations are loaded
184
  $( '#woocommerce-product-data' ).on( 'woocommerce_variations_loaded', function() {
185
- $( '.js-variable-fb-sync-toggle' ).trigger( 'change' );
186
- $( '.js-fb-product-image-source:checked' ).trigger( 'change' );
187
  } );
188
 
189
  let submitProductSave = false;
168
  toggleFacebookSettings( $( this ).prop( 'checked' ), $( this ).closest( '.wc-metabox-content' ) );
169
  } );
170
 
171
+ $( '#woocommerce-product-data' ).on( 'woocommerce_variations_loaded', function () {
172
+
173
+ $( '.js-variable-fb-sync-toggle' ).each( function () {
174
+ toggleFacebookSettings( $( this ).prop( 'checked' ), $( this ).closest( '.wc-metabox-content' ) );
175
+ } );
176
+ } );
177
+
178
  // show/hide Custom Image URL setting
179
  $( '#woocommerce-product-data' ).on( 'change', '.js-fb-product-image-source', function() {
180
 
189
 
190
  // trigger settings fields modifiers when variations are loaded
191
  $( '#woocommerce-product-data' ).on( 'woocommerce_variations_loaded', function() {
192
+ $( '.js-variable-fb-sync-toggle:visible' ).trigger( 'change' );
193
+ $( '.js-fb-product-image-source:checked:visible' ).trigger( 'change' );
194
  } );
195
 
196
  let submitProductSave = false;
assets/js/admin/facebook-for-woocommerce-products-admin.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";jQuery(document).ready(function(s){var o=window.pagenow.length?window.pagenow:"";window.typenow.length&&window.typenow;if("edit-product"===o){var e=s(".facebook-for-woocommerce-product-visibility-toggle");e.tipTip({attribute:"title",edgeOffset:5,fadeIn:50,fadeOut:50,delay:200}),e.on("click",function(o){o.preventDefault();var e=s(this).data("action"),c="show"===e?"yes":"no",t=parseInt(s(this).data("product-id"),10);"show"===e?s(this).hide().next("button").show():"hide"===e&&s(this).hide().prev("button").show(),s.post(facebook_for_woocommerce_products_admin.ajax_url,{action:"facebook_for_woocommerce_set_products_visibility",security:facebook_for_woocommerce_products_admin.set_product_visibility_nonce,products:[{product_id:t,visibility:c}]})});var i=!1;s("input#doaction, input#doaction2").on("click",function(o){if(i)return!0;o.preventDefault();var e=s(this),c=e.prev("select").val();if("facebook_include"===c){var t=[];s.each(s('input[name="post[]"]:checked'),function(){t.push(parseInt(s(this).val(),10))}),s.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?(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-toggle-product-visibility").on("click",function(o){blockModal(),s(this).hasClass("hide-products")&&s.each(t,function(){var o=s("#post-"+this).find("td.facebook_catalog_visibility button.facebook-for-woocommerce-product-visibility-hide");o.is(":visible")&&o.trigger("click")}),i=!0,e.trigger("click")})):(i=!0,e.trigger("click"))})}else i=!0,e.trigger("click")})}if("product"===o){var c=function(o,e){e.find(".enable-if-sync-enabled").prop("disabled",!o)},t=s("#fb_sync_enabled"),a=t.closest(".woocommerce_options_panel");t.on("click",function(){c(s(this).prop("checked"),a)}),c(t.prop("checked"),a),s(".woocommerce_variations").on("change",".js-variable-fb-sync-toggle",function(){c(s(this).prop("checked"),s(this).closest(".wc-metabox-content"))}),s("#woocommerce-product-data").on("change",".js-fb-product-image-source",function(){var o=s(this).closest(".woocommerce_options_panel, .wc-metabox-content"),e=s(this).val();o.find(".product-image-source-field").closest(".form-field").hide(),o.find(".show-if-product-image-source-"+e).closest(".form-field").show()}),s(".js-fb-product-image-source:checked").trigger("change"),s("#woocommerce-product-data").on("woocommerce_variations_loaded",function(){s(".js-variable-fb-sync-toggle").trigger("change"),s(".js-fb-product-image-source:checked").trigger("change")});var d=!1;s('form#post input[type="submit"]').on("click",function(o){if(d)return!0;o.preventDefault();var e=s(this),c=s('input[name="fb_visibility"]'),t=parseInt(s("input#post_ID").val(),10),i=[],a=s('textarea[name="tax_input[product_tag]"]').length?s('textarea[name="tax_input[product_tag]"]').val().split(","):[],n=s("input#fb_sync_enabled").prop("checked"),r=s(".js-variable-fb-sync-toggle").is(":checked");s('#taxonomy-product_cat input[name="tax_input[product_cat][]"]:checked').each(function(){i.push(parseInt(s(this).val(),10))}),s('#taxonomy-product_tag input[name="tax_input[product_tag][]"]:checked').each(function(){a.push(parseInt(s(this).val(),10))}),0<t?s.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:r?"enabled":"disabled",product:t,categories:i,tags:a},function(o){o&&!o.success&&(n||!n&&c.length&&c.is(":checked"))?(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-toggle-product-visibility").on("click",function(o){blockModal(),s(this).hasClass("hide-products")&&c.prop("checked",!1),d=!0,e.trigger("click")})):(d=!0,e.trigger("click"))}):(d=!0,e.trigger("click"))})}"product"!==o&&"edit-product"!==o||s(".js-wc-plugin-framework-admin-notice").on("click",".notice-dismiss-permanently",function(){var o=s(this).closest(".js-wc-plugin-framework-admin-notice");s.get(ajaxurl,{action:"wc_plugin_framework_"+s(o).data("plugin-id")+"_dismiss_notice",messageid:s(o).data("message-id"),permanently:!0}),o.fadeOut()})});
1
+ "use strict";jQuery(document).ready(function(s){var o=window.pagenow.length?window.pagenow:"";window.typenow.length&&window.typenow;if("edit-product"===o){var e=s(".facebook-for-woocommerce-product-visibility-toggle");e.tipTip({attribute:"title",edgeOffset:5,fadeIn:50,fadeOut:50,delay:200}),e.on("click",function(o){o.preventDefault();var e=s(this).data("action"),c="show"===e?"yes":"no",t=parseInt(s(this).data("product-id"),10);"show"===e?s(this).hide().next("button").show():"hide"===e&&s(this).hide().prev("button").show(),s.post(facebook_for_woocommerce_products_admin.ajax_url,{action:"facebook_for_woocommerce_set_products_visibility",security:facebook_for_woocommerce_products_admin.set_product_visibility_nonce,products:[{product_id:t,visibility:c}]})});var i=!1;s("input#doaction, input#doaction2").on("click",function(o){if(i)return!0;o.preventDefault();var e=s(this),c=e.prev("select").val();if("facebook_include"===c){var t=[];s.each(s('input[name="post[]"]:checked'),function(){t.push(parseInt(s(this).val(),10))}),s.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?(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-toggle-product-visibility").on("click",function(o){blockModal(),s(this).hasClass("hide-products")&&s.each(t,function(){var o=s("#post-"+this).find("td.facebook_catalog_visibility button.facebook-for-woocommerce-product-visibility-hide");o.is(":visible")&&o.trigger("click")}),i=!0,e.trigger("click")})):(i=!0,e.trigger("click"))})}else i=!0,e.trigger("click")})}if("product"===o){var c=function(o,e){e.find(".enable-if-sync-enabled").prop("disabled",!o)},t=s("#fb_sync_enabled"),a=t.closest(".woocommerce_options_panel");t.on("click",function(){c(s(this).prop("checked"),a)}),c(t.prop("checked"),a),s(".woocommerce_variations").on("change",".js-variable-fb-sync-toggle",function(){c(s(this).prop("checked"),s(this).closest(".wc-metabox-content"))}),s("#woocommerce-product-data").on("woocommerce_variations_loaded",function(){s(".js-variable-fb-sync-toggle").each(function(){c(s(this).prop("checked"),s(this).closest(".wc-metabox-content"))})}),s("#woocommerce-product-data").on("change",".js-fb-product-image-source",function(){var o=s(this).closest(".woocommerce_options_panel, .wc-metabox-content"),e=s(this).val();o.find(".product-image-source-field").closest(".form-field").hide(),o.find(".show-if-product-image-source-"+e).closest(".form-field").show()}),s(".js-fb-product-image-source:checked").trigger("change"),s("#woocommerce-product-data").on("woocommerce_variations_loaded",function(){s(".js-variable-fb-sync-toggle:visible").trigger("change"),s(".js-fb-product-image-source:checked:visible").trigger("change")});var d=!1;s('form#post input[type="submit"]').on("click",function(o){if(d)return!0;o.preventDefault();var e=s(this),c=s('input[name="fb_visibility"]'),t=parseInt(s("input#post_ID").val(),10),i=[],a=s('textarea[name="tax_input[product_tag]"]').length?s('textarea[name="tax_input[product_tag]"]').val().split(","):[],n=s("input#fb_sync_enabled").prop("checked"),r=s(".js-variable-fb-sync-toggle").is(":checked");s('#taxonomy-product_cat input[name="tax_input[product_cat][]"]:checked').each(function(){i.push(parseInt(s(this).val(),10))}),s('#taxonomy-product_tag input[name="tax_input[product_tag][]"]:checked').each(function(){a.push(parseInt(s(this).val(),10))}),0<t?s.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:r?"enabled":"disabled",product:t,categories:i,tags:a},function(o){o&&!o.success&&(n||!n&&c.length&&c.is(":checked"))?(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-toggle-product-visibility").on("click",function(o){blockModal(),s(this).hasClass("hide-products")&&c.prop("checked",!1),d=!0,e.trigger("click")})):(d=!0,e.trigger("click"))}):(d=!0,e.trigger("click"))})}"product"!==o&&"edit-product"!==o||s(".js-wc-plugin-framework-admin-notice").on("click",".notice-dismiss-permanently",function(){var o=s(this).closest(".js-wc-plugin-framework-admin-notice");s.get(ajaxurl,{action:"wc_plugin_framework_"+s(o).data("plugin-id")+"_dismiss_notice",messageid:s(o).data("message-id"),permanently:!0}),o.fadeOut()})});
assets/js/admin/facebook-for-woocommerce-settings-sync.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";jQuery(document).ready(function(a){if(0!==a('input[name="section"][value="facebookcommerce"]').closest("form").length){a('input[type="checkbox"].toggle-fields-group').on("change",function(e){a(this).hasClass("product-sync-field")?o(a(".product-sync-field").not(".toggle-fields-group"),a(this).is(":checked")):a(this).hasClass("messenger-field")?o(a(".messenger-field").not(".toggle-fields-group"),a(this).is(":checked")):a(this).hasClass("resync-schedule-field")&&o(a(".resync-schedule-field").not(".toggle-fields-group"),a(this).is(":checked"))}).trigger("change"),a("#woocommerce_facebookcommerce_scheduled_resync_hours, #woocommerce_facebookcommerce_scheduled_resync_minutes").on("input change keyup keydown keypress click",function(){var e=a(this).val();!isNaN(e)&&1===e.length&&e<10&&a(this).val(e.padStart(2,"0"))}).trigger("change"),a("textarea#woocommerce_facebookcommerce_messenger_greeting").on("focus change keyup keydown keypress",function(){var e=parseInt(window.facebookAdsToolboxConfig.messengerGreetingMaxCharacters,10),o=a(this).val().length,c=a("span.characters-counter"),s=c.find("span");c.html(o+" / "+e+"<br/>").append(s).css("display","block"),e<o?c.css("color","#DC3232").find("span").show():c.css("color","#999999").find("span").hide()});var l=!1;a(".woocommerce-save-button").on("click",function(e){if(l)return!0;e.preventDefault();var o,c,s,t,i=a(this),n=(s=a("#woocommerce_facebookcommerce_excluded_product_category_ids").val(),t=[],window.facebookAdsToolboxConfig&&window.facebookAdsToolboxConfig.excludedCategoryIDs&&(t=window.facebookAdsToolboxConfig.excludedCategoryIDs),a(s).not(t).get()),r=(o=a("#woocommerce_facebookcommerce_excluded_product_tag_ids").val(),c=[],window.facebookAdsToolboxConfig&&window.facebookAdsToolboxConfig.excludedTagIDs&&(c=window.facebookAdsToolboxConfig.excludedTagIDs),a(o).not(c).get());0<n.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:n,tags:r},function(e){e&&!e.success?(a("#wc-backbone-modal-dialog .modal-close").trigger("click"),new a.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:e.data}),a(".facebook-for-woocommerce-confirm-settings-change").on("click",function(){if(blockModal(),a(this).hasClass("hide-products")){var e=[],o=[];a(n).each(function(){e.push({term_id:this,taxonomy:"product_cat",visibility:!1})}),a(r).each(function(){o.push({term_id:this,taxonomy:"product_tag",visibility:!1})}),a.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"facebook_for_woocommerce_set_products_visibility",security:facebook_for_woocommerce_settings_sync.set_product_visibility_nonce,product_categories:e,product_tags:o},function(e){e&&e.success||console.log(e),l=!0,i.trigger("click")})}else l=!0,i.trigger("click")})):(l=!0,i.trigger("click"))}):(l=!0,i.trigger("click"))})}function o(e,o){a(e).each(function(){var e=a(this);a(this).hasClass("wc-enhanced-select")&&(e=a(this).next("span.select2-container")),o?e.css("pointer-events","all").css("opacity","1.0"):e.css("pointer-events","none").css("opacity","0.4")})}});
1
+ "use strict";jQuery(document).ready(function(n){if(0!==n('input[name="section"][value="facebookcommerce"]').closest("form").length){n('input[type="checkbox"].toggle-fields-group').on("change",function(e){n(this).hasClass("product-sync-field")?o(n(".product-sync-field").not(".toggle-fields-group"),n(this).is(":checked")):n(this).hasClass("messenger-field")?o(n(".messenger-field").not(".toggle-fields-group"),n(this).is(":checked")):n(this).hasClass("resync-schedule-field")&&o(n(".resync-schedule-field").not(".toggle-fields-group"),n(this).is(":checked"))}).trigger("change"),n("#woocommerce_facebookcommerce_scheduled_resync_hours, #woocommerce_facebookcommerce_scheduled_resync_minutes").on("input change keyup keydown keypress click",function(){var e=n(this).val();!isNaN(e)&&1===e.length&&e<10&&n(this).val(e.padStart(2,"0"))}).trigger("change"),n("textarea#woocommerce_facebookcommerce_messenger_greeting").on("focus change keyup keydown keypress",function(){var e=parseInt(window.facebookAdsToolboxConfig.messengerGreetingMaxCharacters,10),o=n(this).val().length,c=n("span.characters-counter"),s=c.find("span");c.html(o+" / "+e+"<br/>").append(s).css("display","block"),e<o?c.css("color","#DC3232").find("span").show():c.css("color","#999999").find("span").hide()});var i=!1;n(".woocommerce-save-button").on("click",function(e){if(i)return!0;e.preventDefault();var c=n(this),s=function(){var e=n("#woocommerce_facebookcommerce_excluded_product_category_ids").val(),o=[];return window.facebookAdsToolboxConfig&&window.facebookAdsToolboxConfig.excludedCategoryIDs&&(o=window.facebookAdsToolboxConfig.excludedCategoryIDs),n(e).not(o).get()}(),t=function(){var e=n("#woocommerce_facebookcommerce_excluded_product_tag_ids").val(),o=[];return window.facebookAdsToolboxConfig&&window.facebookAdsToolboxConfig.excludedTagIDs&&(o=window.facebookAdsToolboxConfig.excludedTagIDs),n(e).not(o).get()}();0<s.length||0<t.length?n.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:s,tags:t},function(e){e&&!e.success?(n("#wc-backbone-modal-dialog .modal-close").trigger("click"),new n.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:e.data}),n(".facebook-for-woocommerce-confirm-settings-change").on("click",function(){if(blockModal(),n(this).hasClass("hide-products")){var e=[],o=[];n(s).each(function(){e.push({term_id:this,taxonomy:"product_cat",visibility:!1})}),n(t).each(function(){o.push({term_id:this,taxonomy:"product_tag",visibility:!1})}),n.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"facebook_for_woocommerce_set_products_visibility",security:facebook_for_woocommerce_settings_sync.set_product_visibility_nonce,product_categories:e,product_tags:o},function(e){e&&e.success||console.log(e),i=!0,c.trigger("click")})}else i=!0,c.trigger("click")})):(i=!0,c.trigger("click"))}):(i=!0,c.trigger("click"))})}function o(e,o){n(e).each(function(){var e=n(this);n(this).hasClass("wc-enhanced-select")&&(e=n(this).next("span.select2-container")),o?e.css("pointer-events","all").css("opacity","1.0"):e.css("pointer-events","none").css("opacity","0.4")})}});
assets/js/facebook-settings.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";var fb_sync_no_response_count=0,fb_show_advanced_options=!1;function openPopup(){var e,o=screen.height/2-404,n=screen.width/2-576.5;window.originParam=window.location.protocol+"//"+window.location.host,window.facebookAdsToolboxConfig.popupOrigin.includes("staticxx")&&(window.facebookAdsToolboxConfig.popupOrigin="https://www.facebook.com/"),window.facebookAdsToolboxConfig.popupOrigin=prepend_protocol(window.facebookAdsToolboxConfig.popupOrigin),e=window.facebookAdsToolboxConfig.popupOrigin;var t=window.open(e+"/login.php?display=popup&next="+encodeURIComponent(e+"/ads/dia?origin="+window.originParam+" &merchant_settings_id="+window.facebookAdsToolboxConfig.diaSettingId),"DiaWizard",["toolbar=no","location=no","directories=no","status=no","menubar=no","scrollbars=no","resizable=no","copyhistory=no","width=1153","height=808","top="+o,"left="+n].join(","));return function(e,o){t.postMessage({type:e,params:o},window.facebookAdsToolboxConfig.popupOrigin)}}function prepend_protocol(e){return 0===e.indexOf("//www.")&&(e="https:"+e),e}function get_pixel_id_box(){return document.querySelector("#woocommerce_facebookcommerce_facebook_pixel_id")}function get_pixel_use_pii_id_box(){return document.querySelector("#woocommerce_facebookcommerce_enable_advanced_matching")}function get_page_id_box(){return document.querySelector("#woocommerce_facebookcommerce_facebook_page_id")}function ajax(e){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,t=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,s=Object.assign({},{action:e},o);jQuery.post(ajaxurl,s,function(e){n&&n(e)}).fail(function(e){t&&t(e)})}var settings={facebook_for_woocommerce:1},pixel_settings={facebook_for_woocommerce:1};function facebookConfig(){window.sendToFacebook=openPopup(),window.diaConfig={clientSetup:window.facebookAdsToolboxConfig}}function fb_flush(){return console.log("Removing all FBIDs from all products!"),ajax("ajax_reset_all_fb_products",{_ajax_nonce:wc_facebook_settings_jsx.nonce},null,function(){console.log("Failed to reset all FB products")})}function sync_confirm(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,o="";switch(e){case"fb_force_resync":o=facebook_for_woocommerce_settings_sync.i18n.confirm_resync;break;case"fb_test_product_sync":o=facebook_for_woocommerce_settings_sync.i18n.confirm_sync_test;break;default:o=facebook_for_woocommerce_settings_sync.i18n.confirm_sync}confirm(o)&&(sync_all_products(window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload,"fb_test_product_sync"==e),window.fb_sync_start_time=(new Date).getTime())}function sync_all_products(){var n=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];window.fb_connected=!0,sync_in_progress();var o={};o=n?(window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload=!0,window.feed_upload=!0,ping_feed_status_queue(),e?{action:"ajax_test_sync_products_using_feed"}:{action:"ajax_sync_all_fb_products_using_feed",_ajax_nonce:wc_facebook_settings_jsx.nonce}):(check_background_processor_status(),{action:"ajax_sync_all_fb_products",_ajax_nonce:wc_facebook_settings_jsx.nonce}),jQuery.post(ajaxurl,o).then(function(e){if(!e&&n||e&&!1===e.success){clearInterval(window.fb_pings),clearInterval(window.fb_feed_pings),jQuery("#woocommerce-facebook-settings-manage-connection, #woocommerce-facebook-settings-sync-products").css("pointer-events","auto");var o=void 0;o=e&&e.data&&e.data.error?e.data.error:facebook_for_woocommerce_settings_sync.i18n.general_error,jQuery("#sync_progress").show().html('<span style="color: #DC3232">'+o+"</span>")}})}function delete_all_settings(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return get_pixel_id_box()&&(get_pixel_id_box().value=""),get_pixel_use_pii_id_box()&&(get_pixel_use_pii_id_box().checked=!1),get_page_id_box()&&(get_page_id_box().value=""),jQuery("#woocommerce_facebookcommerce_enable_messenger").prop("checked",!1).trigger("change"),jQuery(".messenger-field").each(function(){void 0!==jQuery(this).data("default")&&jQuery(this).val(jQuery(this).data("default")).trigger("change")}),window.facebookAdsToolboxConfig.pixel.pixelId="",window.facebookAdsToolboxConfig.diaSettingId="",window.fb_connected=!1,not_connected(),console.log("Deleting all settings and removing all FBIDs!"),ajax("ajax_delete_fb_settings",{_ajax_nonce:wc_facebook_settings_jsx.nonce},e,o)}function save_settings(){var o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;(e=e||settings)._ajax_nonce=wc_facebook_settings_jsx.nonce,ajax("ajax_save_fb_settings",e,function(e){o&&o(e)},function(e){n&&n(e)})}function save_settings_for_plugin(o,n){save_settings(function(e){e&&!0===e.success?(console.log(e),o(e)):(console.log("Fail response on save_settings_for_plugin"),n(e))},function(e){console.log("Ajax error while saving settings:"+JSON.stringify(e)),n(e)})}function save_settings_and_sync(o){"api_key"in settings&&save_settings(function(e){e&&e.includes("settings_saved")?(console.log(e),window.sendToFacebook("ack set pixel",o.params),window.sendToFacebook("ack set page access token",o.params),window.sendToFacebook("ack set merchant settings",o.params)):(window.sendToFacebook("fail save_settings",e),console.log("Fail response on save_settings_and_sync"))},function(e){console.log("Ajax error while saving settings:"+JSON.stringify(e)),window.sendToFacebook("fail save_settings_ajax",JSON.stringify(e))})}function sync_in_progress(){jQuery("#woocommerce-facebook-settings-manage-connection, #woocommerce-facebook-settings-sync-products").css("pointer-events","none"),jQuery("#sync_progress").show().html(facebook_for_woocommerce_settings_sync.i18n.sync_in_progress)}function sync_not_in_progress(){jQuery("#woocommerce-facebook-settings-manage-connection, #woocommerce-facebook-settings-sync-products").css("pointer-events","auto"),jQuery("#sync_progress").empty().hide()}function not_connected(){jQuery("#fbsetup").show(),jQuery("#integration-settings").hide(),jQuery(".woocommerce-save-button").hide()}function addAnEventListener(e,o,n){"addEventListener"in e?e.addEventListener(o,n,!1):"attachEvent"in e&&e.attachEvent("on"+o,n)}function setMerchantSettings(e){if(!e.params.setting_id)return console.error("Facebook Extension Error: got no setting_id",e.params),void window.sendToFacebook("fail set merchant settings",e.params);settings.external_merchant_settings_id=e.params.setting_id,window.facebookAdsToolboxConfig.diaSettingId=e.params.setting_id}function setCatalog(e){if(!e.params.catalog_id)return console.error("Facebook Extension Error: got no catalog_id",e.params),void window.sendToFacebook("fail set catalog",e.params);settings.product_catalog_id=e.params.catalog_id,window.sendToFacebook("ack set catalog",e.params)}function setPixel(o){if(!o.params.pixel_id)return console.error("Facebook Ads Extension Error: got no pixel_id",o.params),void window.sendToFacebook("fail set pixel",o.params);get_pixel_id_box()&&(get_pixel_id_box().value=o.params.pixel_id),settings.pixel_id=o.params.pixel_id,pixel_settings.pixel_id=settings.pixel_id,void 0!==o.params.pixel_use_pii&&(get_pixel_use_pii_id_box()&&(get_pixel_use_pii_id_box().checked=!!o.params.pixel_use_pii),settings.pixel_use_pii=o.params.pixel_use_pii,pixel_settings.pixel_use_pii=settings.pixel_use_pii),save_settings(function(e){e&&!0===e.success&&window.sendToFacebook("ack set pixel",o.params)},function(e){console.log(e),window.sendToFacebook("fail set pixel",e)},pixel_settings)}function genFeed(t){console.log("generating feed"),jQuery.get(window.facebookAdsToolboxConfig.feedPrepared.feedUrl+"&regenerate=true").done(function(e){window.sendToFacebook("ack feed",t.params)}).fail(function(e,o,n){window.sendToFacebook("fail feed",t.params)})}function setAccessTokenAndPageId(e){if(!e.params.page_token)return console.error("Facebook Ads Extension Error: got no page_token",e.params),void window.sendToFacebook("fail set page access token",e.params);get_page_id_box()&&(get_page_id_box().value=e.params.page_id),settings.api_key=e.params.page_token,settings.page_id=e.params.page_id,window.facebookAdsToolboxConfig.tokenExpired=!1,document.querySelector("#connection-message-invalid")&&(document.querySelector("#connection-message-invalid").style.display="none"),document.querySelector("#connection-message-refresh")&&(document.querySelector("#connection-message-refresh").style.display="block")}function setMsgerChatSetup(e){if(e.hasOwnProperty("is_messenger_chat_plugin_enabled")&&(settings.is_messenger_chat_plugin_enabled=e.is_messenger_chat_plugin_enabled,jQuery("#woocommerce_facebookcommerce_enable_messenger").prop("checked",e.is_messenger_chat_plugin_enabled).trigger("change")),e.hasOwnProperty("facebook_jssdk_version")&&(settings.facebook_jssdk_version=e.facebook_jssdk_version),e.hasOwnProperty("page_id")&&(settings.fb_page_id=e.page_id),e.hasOwnProperty("customization")){var o=e.customization;o.hasOwnProperty("greetingTextCode")&&(settings.msger_chat_customization_greeting_text_code=o.greetingTextCode,jQuery("#woocommerce_facebookcommerce_messenger_greeting").val(o.greetingTextCode).trigger("change")),o.hasOwnProperty("locale")&&(settings.msger_chat_customization_locale=o.locale,jQuery("#woocommerce_facebookcommerce_messenger_locale").val(o.locale).trigger("change")),o.hasOwnProperty("themeColorCode")&&(settings.msger_chat_customization_theme_color_code=o.themeColorCode,jQuery("#woocommerce_facebookcommerce_messenger_color_hex").val(o.themeColorCode).trigger("change"))}}function setFeedMigrated(e){if(!e.params.hasOwnProperty("feed_migrated"))return console.error("Facebook Extension Error: feed migrated not received",e.params),void window.sendToFacebook("fail set feed migrated",e.params);settings.feed_migrated=e.params.feed_migrated,window.facebookAdsToolboxConfig.feedPrepared.feedMigrated=e.params.feed_migrated,jQuery("#woocommerce-facebook-settings-sync-products").hide(),jQuery(".notice.wc-facebook-migrate-notice").hide(),save_settings_for_plugin(function(e){window.sendToFacebook("ack set feed migrated",event.data)},function(e){window.sendToFacebook("fail set feed migrated",event.data)})}function iFrameListener(o){var e=o.origin||o.originalEvent.origin;if(e!==window.facebookAdsToolboxConfig.popupOrigin){if(!urlFromSameDomain(e,window.facebookAdsToolboxConfig.popupOrigin))return;window.facebookAdsToolboxConfig.popupOrigin=e}switch(o.data.type){case"reset":delete_all_settings(function(e){e&&o.data.params?"Settings Deleted"===e?window.sendToFacebook("ack reset",o.data.params):(console.log(e),alert(e)):console.log("Got no response from delete_all_settings")},function(e){console.error(e)});break;case"get dia settings":window.sendToFacebook("dia settings",window.diaConfig);break;case"set catalog":setCatalog(o.data);break;case"set feed migrated":setFeedMigrated(o.data);break;case"set pixel":setPixel(o.data);break;case"gen feed":genFeed(o.data);break;case"set page access token":window.sendToFacebook("ack set page access token",o.data.params);break;case"set page":setPage(o.data);break;case"set merchant settings":setMerchantSettings(o.data),save_settings(function(e){console.log(e),e&&!0===e.success?(settings.pixel_id&&window.sendToFacebook("ack set pixel",o.data.params),settings.page_id&&window.sendToFacebook("ack set page",o.data.params),settings.external_merchant_settings_id&&(window.sendToFacebook("ack set merchant settings",o.data.params),jQuery("#fbsetup").hide(),jQuery("#integration-settings").show(),jQuery(".woocommerce-save-button").show())):(window.sendToFacebook("fail save_settings",e),console.log("Fail response on save_settings"))},function(e){console.log("Ajax error while saving settings:"+JSON.stringify(e)),window.sendToFacebook("fail save_settings_ajax",JSON.stringify(e))});break;case"set msger chat":setMsgerChatSetup(o.data.params),save_settings_for_plugin(function(e){window.sendToFacebook("ack msger chat",o.data)},function(e){window.sendToFacebook("fail msger chat",o.data)})}}function setPage(e){if(!e.params.hasOwnProperty("page_id"))return console.error("Facebook Extension Error: page ID not received",e.params),void window.sendToFacebook("fail set page",e.params);settings.page_id=e.params.page_id,jQuery("#woocommerce_facebookcommerce_facebook_page_id").val(settings.page_id)}function urlFromSameDomain(e,o){if(!e.startsWith("http")||!o.startsWith("http"))return!1;var n=parseURL(e),t=parseURL(o),s=n.host.replace(/^\w+\./,"www."),i=t.host.replace(/^\w+\./,"www.");return n.protocol===t.protocol&&s===i}function parseURL(e){var o=document.createElement("a");return o.href=e,o}function check_background_processor_status(){window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload||(clearInterval(window.fb_pings),window.fb_pings=setInterval(function(){console.log("Pinging queue..."),check_queues()},1e4))}function ping_feed_status_queue(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;clearInterval(window.fb_feed_pings),window.fb_feed_pings=setInterval(function(){console.log("Pinging feed uploading queue..."),check_feed_upload_queue(e)},3e4*(1<<e))}function product_sync_complete(e){sync_not_in_progress(),e.empty().hide(),clearInterval(window.fb_pings)}function check_queues(){ajax("ajax_fb_background_check_queue",{request_time:(new Date).getTime(),_ajax_nonce:wc_facebook_settings_jsx.nonce},function(e){if(window.feed_upload)clearInterval(window.fb_pings);else{var o=jQuery("#sync_progress"),n=parse_response_check_connection(e);if(n){if(fb_sync_no_response_count=0,n){n.background||(console.log("No background sync found, disabling pings"),clearInterval(window.fb_pings));var t=!!n.processing,s=n.remaining;if(t){var i="";i=1===s?facebook_for_woocommerce_settings_sync.i18n.sync_remaining_items_singular:facebook_for_woocommerce_settings_sync.i18n.sync_remaining_items_plural,o.show().html(i.replace("{count}",s)),0===s&&product_sync_complete(o)}else{if(window.fb_sync_start_time&&n.request_time){var a=new Date(parseInt(n.request_time));if(window.fb_sync_start_time>a)return void console.log("OLD PING")}0===s&&product_sync_complete(o)}}}else 5<fb_sync_no_response_count++&&clearInterval(window.fb_pings)}})}function parse_response_check_connection(e){if(e){console.log(e);var o=e.substring(e.indexOf("{"));return(o=JSON.parse(o)).connected||window.fb_connected?o:(not_connected(),null)}return null}function check_feed_upload_queue(t){ajax("ajax_check_feed_upload_status",{_ajax_nonce:wc_facebook_settings_jsx.nonce},function(e){var o=jQuery("#sync_progress"),n=parse_response_check_connection(e);if(clearInterval(window.fb_feed_pings),n)switch(n.status){case"complete":window.feed_upload=!1,window.is_test?display_test_result():product_sync_complete(o);break;case"in progress":o.show().html(facebook_for_woocommerce_settings_sync.i18n.sync_in_progress),ping_feed_status_queue(t+1);break;default:jQuery("#woocommerce-facebook-settings-manage-connection, #woocommerce-facebook-settings-sync-products").css("pointer-events","auto"),jQuery("#sync_progress").show().html('<span style="color: #DC3232">'+facebook_for_woocommerce_settings_sync.i18n.feed_upload_error+"</span>"),window.feed_upload=!1,window.is_test&&display_test_result()}})}function display_test_result(){ajax("ajax_display_test_result",{_ajax_nonce:wc_facebook_settings_jsx.nonce},function(e){var o=jQuery("#sync_progress"),n=document.querySelector("#sync_complete"),t=parse_response_check_connection(e);if(t)switch(t.pass){case"true":sync_not_in_progress(),n&&(n.style.display="",n.innerHTML=facebook_for_woocommerce_settings_sync.i18n.integration_test_sucessful),o.empty().hide(),window.is_test=!1;break;case"in progress":o.show().html(facebook_for_woocommerce_settings_sync.i18n.integration_test_in_progress),ping_feed_status_queue();break;default:window.debug_info=t.debug_info+"<br/>"+t.stack_trace,n&&(n.style.display="",n.innerHTML=facebook_for_woocommerce_settings_sync.i18n.integration_test_failed),o.empty().hide(),document.querySelector("#debug_info")&&(document.querySelector("#debug_info").style.display=""),window.is_test=!1}})}function show_debug_info(){var e=document.querySelector("#stack_trace");e&&(e.innerHTML=window.debug_info),document.querySelector("#debug_info")&&(document.querySelector("#debug_info").style.display="none"),window.debug_info=""}function fbe_init_nux_messages(){var r=window.jQuery;r(function(){r.each(r(".nux-message"),function(e,o){var n=r(o),t=n.data("target"),s=r("#"+t),i=s.position(),a=s.height()/2,c=s.outerWidth();n.css({top:Math.ceil(i.top+a)+"px",left:Math.ceil(i.left+c)+"px",display:"block"}),r(".nux-message-close-btn",n).click(function(){r(o).hide()})})})}function saveAutoSyncSchedule(){var e=document.getElementsByClassName("autosyncCheck")[0].checked,o=document.getElementsByClassName("autosyncTime")[0],n=(document.getElementsByClassName("autosyncSaveButton")[0],document.getElementsByClassName("autosyncSavedNotice")[0]);e?(o.removeAttribute("disabled"),n.style.transition="",n.style.opacity=1,setTimeout(function(){n.style.opacity=0,n.style.transition="opacity 5s"},3e3)):o.setAttribute("disabled",!0),ajax("ajax_schedule_force_resync",{enabled:e?1:0,time:o.value,_ajax_nonce:wc_facebook_settings_jsx.nonce})}function syncShortDescription(){var e=document.getElementsByClassName("syncShortDescription")[0].checked;ajax("ajax_update_fb_option",{option:"fb_sync_short_description",option_value:e?1:0,_ajax_nonce:wc_facebook_settings_jsx.nonce},null,function(){document.getElementsByClassName("syncShortDescription")[0].checked=!e,console.log("Failed to sync Short Description")})}addAnEventListener(window,"message",iFrameListener),jQuery(document).ready(function(e){e(".notice .wc-facebook-manage-connection").click(function(e){e.preventDefault(),facebookConfig()}),e("#woocommerce-facebook-settings-sync-products").click(function(e){e.preventDefault(),sync_confirm()})});
1
+ "use strict";var fb_sync_no_response_count=0,fb_show_advanced_options=!1;function openPopup(){var e,o=screen.height/2-404,n=screen.width/2-576.5;window.originParam=window.location.protocol+"//"+window.location.host,window.facebookAdsToolboxConfig.popupOrigin.includes("staticxx")&&(window.facebookAdsToolboxConfig.popupOrigin="https://www.facebook.com/"),window.facebookAdsToolboxConfig.popupOrigin=prepend_protocol(window.facebookAdsToolboxConfig.popupOrigin),e=window.facebookAdsToolboxConfig.popupOrigin;var t=window.open(e+"/login.php?display=popup&next="+encodeURIComponent(e+"/ads/dia?origin="+window.originParam+" &merchant_settings_id="+window.facebookAdsToolboxConfig.diaSettingId),"DiaWizard",["toolbar=no","location=no","directories=no","status=no","menubar=no","scrollbars=no","resizable=no","copyhistory=no","width=1153","height=808","top="+o,"left="+n].join(","));return function(e,o){t.postMessage({type:e,params:o},window.facebookAdsToolboxConfig.popupOrigin)}}function prepend_protocol(e){return 0===e.indexOf("//www.")&&(e="https:"+e),e}function get_pixel_id_box(){return document.querySelector("#woocommerce_facebookcommerce_facebook_pixel_id")}function get_pixel_use_pii_id_box(){return document.querySelector("#woocommerce_facebookcommerce_enable_advanced_matching")}function get_page_id_box(){return document.querySelector("#woocommerce_facebookcommerce_facebook_page_id")}function ajax(e){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,t=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,s=Object.assign({},{action:e},o);jQuery.post(ajaxurl,s,function(e){n&&n(e)}).fail(function(e){t&&t(e)})}var settings={facebook_for_woocommerce:1},pixel_settings={facebook_for_woocommerce:1};function facebookConfig(){window.sendToFacebook=openPopup(),window.diaConfig={clientSetup:window.facebookAdsToolboxConfig}}function fb_flush(){return console.log("Removing all FBIDs from all products!"),ajax("ajax_reset_all_fb_products",{_ajax_nonce:wc_facebook_settings_jsx.nonce},null,function(e){console.log("Failed to reset all FB products")})}function sync_confirm(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,o="";switch(e){case"fb_force_resync":o=facebook_for_woocommerce_settings_sync.i18n.confirm_resync;break;case"fb_test_product_sync":o=facebook_for_woocommerce_settings_sync.i18n.confirm_sync_test;break;default:o=facebook_for_woocommerce_settings_sync.i18n.confirm_sync}confirm(o)&&(sync_all_products(window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload,"fb_test_product_sync"==e),window.fb_sync_start_time=(new Date).getTime())}function sync_all_products(){var n=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];window.fb_connected=!0,sync_in_progress();var o={};o=n?(window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload=!0,window.feed_upload=!0,ping_feed_status_queue(),e?{action:"ajax_test_sync_products_using_feed"}:{action:"ajax_sync_all_fb_products_using_feed",_ajax_nonce:wc_facebook_settings_jsx.nonce}):(check_background_processor_status(),{action:"ajax_sync_all_fb_products",_ajax_nonce:wc_facebook_settings_jsx.nonce}),jQuery.post(ajaxurl,o).then(function(e){if(!e&&n||e&&!1===e.success){clearInterval(window.fb_pings),clearInterval(window.fb_feed_pings),jQuery("#woocommerce-facebook-settings-manage-connection, #woocommerce-facebook-settings-sync-products").css("pointer-events","auto");var o=void 0;o=e&&e.data&&e.data.error?e.data.error:facebook_for_woocommerce_settings_sync.i18n.general_error,jQuery("#sync_progress").show().html('<span style="color: #DC3232">'+o+"</span>")}})}function delete_all_settings(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return get_pixel_id_box()&&(get_pixel_id_box().value=""),get_pixel_use_pii_id_box()&&(get_pixel_use_pii_id_box().checked=!1),get_page_id_box()&&(get_page_id_box().value=""),jQuery("#woocommerce_facebookcommerce_enable_messenger").prop("checked",!1).trigger("change"),jQuery(".messenger-field").each(function(){void 0!==jQuery(this).data("default")&&jQuery(this).val(jQuery(this).data("default")).trigger("change")}),window.facebookAdsToolboxConfig.pixel.pixelId="",window.facebookAdsToolboxConfig.diaSettingId="",window.fb_connected=!1,not_connected(),console.log("Deleting all settings and removing all FBIDs!"),ajax("ajax_delete_fb_settings",{_ajax_nonce:wc_facebook_settings_jsx.nonce},e,o)}function save_settings(){var o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;(e=e||settings)._ajax_nonce=wc_facebook_settings_jsx.nonce,ajax("ajax_save_fb_settings",e,function(e){o&&o(e)},function(e){n&&n(e)})}function save_settings_for_plugin(o,n){save_settings(function(e){e&&!0===e.success?(console.log(e),o(e)):(console.log("Fail response on save_settings_for_plugin"),n(e))},function(e){console.log("Ajax error while saving settings:"+JSON.stringify(e)),n(e)})}function save_settings_and_sync(o){"api_key"in settings&&save_settings(function(e){e&&e.includes("settings_saved")?(console.log(e),window.sendToFacebook("ack set pixel",o.params),window.sendToFacebook("ack set page access token",o.params),window.sendToFacebook("ack set merchant settings",o.params)):(window.sendToFacebook("fail save_settings",e),console.log("Fail response on save_settings_and_sync"))},function(e){console.log("Ajax error while saving settings:"+JSON.stringify(e)),window.sendToFacebook("fail save_settings_ajax",JSON.stringify(e))})}function sync_in_progress(){jQuery("#woocommerce-facebook-settings-manage-connection, #woocommerce-facebook-settings-sync-products").css("pointer-events","none"),jQuery("#sync_progress").show().html(facebook_for_woocommerce_settings_sync.i18n.sync_in_progress)}function sync_not_in_progress(){jQuery("#woocommerce-facebook-settings-manage-connection, #woocommerce-facebook-settings-sync-products").css("pointer-events","auto"),jQuery("#sync_progress").empty().hide()}function not_connected(){jQuery("#fbsetup").show(),jQuery("#integration-settings").hide(),jQuery(".woocommerce-save-button").hide()}function addAnEventListener(e,o,n){"addEventListener"in e?e.addEventListener(o,n,!1):"attachEvent"in e&&e.attachEvent("on"+o,n)}function setMerchantSettings(e){if(!e.params.setting_id)return console.error("Facebook Extension Error: got no setting_id",e.params),void window.sendToFacebook("fail set merchant settings",e.params);settings.external_merchant_settings_id=e.params.setting_id,window.facebookAdsToolboxConfig.diaSettingId=e.params.setting_id}function setCatalog(e){if(!e.params.catalog_id)return console.error("Facebook Extension Error: got no catalog_id",e.params),void window.sendToFacebook("fail set catalog",e.params);settings.product_catalog_id=e.params.catalog_id,window.sendToFacebook("ack set catalog",e.params)}function setPixel(o){if(!o.params.pixel_id)return console.error("Facebook Ads Extension Error: got no pixel_id",o.params),void window.sendToFacebook("fail set pixel",o.params);get_pixel_id_box()&&(get_pixel_id_box().value=o.params.pixel_id),settings.pixel_id=o.params.pixel_id,pixel_settings.pixel_id=settings.pixel_id,void 0!==o.params.pixel_use_pii&&(get_pixel_use_pii_id_box()&&(get_pixel_use_pii_id_box().checked=!!o.params.pixel_use_pii),settings.pixel_use_pii=o.params.pixel_use_pii,pixel_settings.pixel_use_pii=settings.pixel_use_pii),save_settings(function(e){e&&!0===e.success&&window.sendToFacebook("ack set pixel",o.params)},function(e){console.log(e),window.sendToFacebook("fail set pixel",e)},pixel_settings)}function genFeed(t){console.log("generating feed"),jQuery.get(window.facebookAdsToolboxConfig.feedPrepared.feedUrl+"&regenerate=true").done(function(e){window.sendToFacebook("ack feed",t.params)}).fail(function(e,o,n){window.sendToFacebook("fail feed",t.params)})}function setAccessTokenAndPageId(e){if(!e.params.page_token)return console.error("Facebook Ads Extension Error: got no page_token",e.params),void window.sendToFacebook("fail set page access token",e.params);get_page_id_box()&&(get_page_id_box().value=e.params.page_id),settings.api_key=e.params.page_token,settings.page_id=e.params.page_id,window.facebookAdsToolboxConfig.tokenExpired=!1,document.querySelector("#connection-message-invalid")&&(document.querySelector("#connection-message-invalid").style.display="none"),document.querySelector("#connection-message-refresh")&&(document.querySelector("#connection-message-refresh").style.display="block")}function setMsgerChatSetup(e){if(e.hasOwnProperty("is_messenger_chat_plugin_enabled")&&(settings.is_messenger_chat_plugin_enabled=e.is_messenger_chat_plugin_enabled,jQuery("#woocommerce_facebookcommerce_enable_messenger").prop("checked",e.is_messenger_chat_plugin_enabled).trigger("change")),e.hasOwnProperty("facebook_jssdk_version")&&(settings.facebook_jssdk_version=e.facebook_jssdk_version),e.hasOwnProperty("page_id")&&(settings.fb_page_id=e.page_id),e.hasOwnProperty("customization")){var o=e.customization;o.hasOwnProperty("greetingTextCode")&&(settings.msger_chat_customization_greeting_text_code=o.greetingTextCode,jQuery("#woocommerce_facebookcommerce_messenger_greeting").val(o.greetingTextCode).trigger("change")),o.hasOwnProperty("locale")&&(settings.msger_chat_customization_locale=o.locale,jQuery("#woocommerce_facebookcommerce_messenger_locale").val(o.locale).trigger("change")),o.hasOwnProperty("themeColorCode")&&(settings.msger_chat_customization_theme_color_code=o.themeColorCode,jQuery("#woocommerce_facebookcommerce_messenger_color_hex").val(o.themeColorCode).trigger("change"))}}function setFeedMigrated(e){if(!e.params.hasOwnProperty("feed_migrated"))return console.error("Facebook Extension Error: feed migrated not received",e.params),void window.sendToFacebook("fail set feed migrated",e.params);settings.feed_migrated=e.params.feed_migrated,window.facebookAdsToolboxConfig.feedPrepared.feedMigrated=e.params.feed_migrated,jQuery("#woocommerce-facebook-settings-sync-products").hide(),jQuery(".notice.wc-facebook-migrate-notice").hide(),save_settings_for_plugin(function(e){window.sendToFacebook("ack set feed migrated",event.data)},function(e){window.sendToFacebook("fail set feed migrated",event.data)})}function iFrameListener(o){var e=o.origin||o.originalEvent.origin;if(e!==window.facebookAdsToolboxConfig.popupOrigin){if(!urlFromSameDomain(e,window.facebookAdsToolboxConfig.popupOrigin))return;window.facebookAdsToolboxConfig.popupOrigin=e}switch(o.data.type){case"reset":delete_all_settings(function(e){e&&o.data.params?"Settings Deleted"===e?window.sendToFacebook("ack reset",o.data.params):(console.log(e),alert(e)):console.log("Got no response from delete_all_settings")},function(e){console.error(e)});break;case"get dia settings":window.sendToFacebook("dia settings",window.diaConfig);break;case"set catalog":setCatalog(o.data);break;case"set feed migrated":setFeedMigrated(o.data);break;case"set pixel":setPixel(o.data);break;case"gen feed":genFeed(o.data);break;case"set page access token":window.sendToFacebook("ack set page access token",o.data.params);break;case"set page":setPage(o.data);break;case"set merchant settings":setMerchantSettings(o.data),save_settings(function(e){console.log(e),e&&!0===e.success?(settings.pixel_id&&window.sendToFacebook("ack set pixel",o.data.params),settings.page_id&&window.sendToFacebook("ack set page",o.data.params),settings.external_merchant_settings_id&&(window.sendToFacebook("ack set merchant settings",o.data.params),jQuery("#fbsetup").hide(),jQuery("#integration-settings").show(),jQuery(".woocommerce-save-button").show())):(window.sendToFacebook("fail save_settings",e),console.log("Fail response on save_settings"))},function(e){console.log("Ajax error while saving settings:"+JSON.stringify(e)),window.sendToFacebook("fail save_settings_ajax",JSON.stringify(e))});break;case"set msger chat":setMsgerChatSetup(o.data.params),save_settings_for_plugin(function(e){window.sendToFacebook("ack msger chat",o.data)},function(e){window.sendToFacebook("fail msger chat",o.data)})}}function setPage(e){if(!e.params.hasOwnProperty("page_id"))return console.error("Facebook Extension Error: page ID not received",e.params),void window.sendToFacebook("fail set page",e.params);settings.page_id=e.params.page_id,jQuery("#woocommerce_facebookcommerce_facebook_page_id").val(settings.page_id)}function urlFromSameDomain(e,o){if(!e.startsWith("http")||!o.startsWith("http"))return!1;var n=parseURL(e),t=parseURL(o),s=n.host.replace(/^\w+\./,"www."),i=t.host.replace(/^\w+\./,"www.");return n.protocol===t.protocol&&s===i}function parseURL(e){var o=document.createElement("a");return o.href=e,o}function check_background_processor_status(){window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload||(clearInterval(window.fb_pings),window.fb_pings=setInterval(function(){console.log("Pinging queue..."),check_queues()},1e4))}function ping_feed_status_queue(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;clearInterval(window.fb_feed_pings),window.fb_feed_pings=setInterval(function(){console.log("Pinging feed uploading queue..."),check_feed_upload_queue(e)},3e4*(1<<e))}function product_sync_complete(e){sync_not_in_progress(),e.empty().hide(),clearInterval(window.fb_pings)}function check_queues(){ajax("ajax_fb_background_check_queue",{request_time:(new Date).getTime(),_ajax_nonce:wc_facebook_settings_jsx.nonce},function(e){if(window.feed_upload)clearInterval(window.fb_pings);else{var o=jQuery("#sync_progress"),n=parse_response_check_connection(e);if(n){if(fb_sync_no_response_count=0,n){n.background||(console.log("No background sync found, disabling pings"),clearInterval(window.fb_pings));var t=!!n.processing,s=n.remaining;if(t){var i="";i=1===s?facebook_for_woocommerce_settings_sync.i18n.sync_remaining_items_singular:facebook_for_woocommerce_settings_sync.i18n.sync_remaining_items_plural,o.show().html(i.replace("{count}",s)),0===s&&product_sync_complete(o)}else{if(window.fb_sync_start_time&&n.request_time){var a=new Date(parseInt(n.request_time));if(window.fb_sync_start_time>a)return void console.log("OLD PING")}0===s&&product_sync_complete(o)}}}else 5<fb_sync_no_response_count++&&clearInterval(window.fb_pings)}})}function parse_response_check_connection(e){if(e){console.log(e);var o=e.substring(e.indexOf("{"));return(o=JSON.parse(o)).connected||window.fb_connected?o:(not_connected(),null)}return null}function check_feed_upload_queue(t){ajax("ajax_check_feed_upload_status",{_ajax_nonce:wc_facebook_settings_jsx.nonce},function(e){var o=jQuery("#sync_progress"),n=parse_response_check_connection(e);if(clearInterval(window.fb_feed_pings),n)switch(n.status){case"complete":window.feed_upload=!1,window.is_test?display_test_result():product_sync_complete(o);break;case"in progress":o.show().html(facebook_for_woocommerce_settings_sync.i18n.sync_in_progress),ping_feed_status_queue(t+1);break;default:jQuery("#woocommerce-facebook-settings-manage-connection, #woocommerce-facebook-settings-sync-products").css("pointer-events","auto"),jQuery("#sync_progress").show().html('<span style="color: #DC3232">'+facebook_for_woocommerce_settings_sync.i18n.feed_upload_error+"</span>"),window.feed_upload=!1,window.is_test&&display_test_result()}})}function display_test_result(){ajax("ajax_display_test_result",{_ajax_nonce:wc_facebook_settings_jsx.nonce},function(e){var o=jQuery("#sync_progress"),n=document.querySelector("#sync_complete"),t=parse_response_check_connection(e);if(t)switch(t.pass){case"true":sync_not_in_progress(),n&&(n.style.display="",n.innerHTML=facebook_for_woocommerce_settings_sync.i18n.integration_test_sucessful),o.empty().hide(),window.is_test=!1;break;case"in progress":o.show().html(facebook_for_woocommerce_settings_sync.i18n.integration_test_in_progress),ping_feed_status_queue();break;default:window.debug_info=t.debug_info+"<br/>"+t.stack_trace,n&&(n.style.display="",n.innerHTML=facebook_for_woocommerce_settings_sync.i18n.integration_test_failed),o.empty().hide(),document.querySelector("#debug_info")&&(document.querySelector("#debug_info").style.display=""),window.is_test=!1}})}function show_debug_info(){var e=document.querySelector("#stack_trace");e&&(e.innerHTML=window.debug_info),document.querySelector("#debug_info")&&(document.querySelector("#debug_info").style.display="none"),window.debug_info=""}function fbe_init_nux_messages(){var r=window.jQuery;r(function(){r.each(r(".nux-message"),function(e,o){var n=r(o),t=n.data("target"),s=r("#"+t),i=s.position(),a=s.height()/2,c=s.outerWidth();n.css({top:Math.ceil(i.top+a)+"px",left:Math.ceil(i.left+c)+"px",display:"block"}),r(".nux-message-close-btn",n).click(function(){r(o).hide()})})})}function saveAutoSyncSchedule(){var e=document.getElementsByClassName("autosyncCheck")[0].checked,o=document.getElementsByClassName("autosyncTime")[0],n=(document.getElementsByClassName("autosyncSaveButton")[0],document.getElementsByClassName("autosyncSavedNotice")[0]);e?(o.removeAttribute("disabled"),n.style.transition="",n.style.opacity=1,setTimeout(function(){n.style.opacity=0,n.style.transition="opacity 5s"},3e3)):o.setAttribute("disabled",!0),ajax("ajax_schedule_force_resync",{enabled:e?1:0,time:o.value,_ajax_nonce:wc_facebook_settings_jsx.nonce})}function syncShortDescription(){var o=document.getElementsByClassName("syncShortDescription")[0].checked;ajax("ajax_update_fb_option",{option:"fb_sync_short_description",option_value:o?1:0,_ajax_nonce:wc_facebook_settings_jsx.nonce},null,function(e){document.getElementsByClassName("syncShortDescription")[0].checked=!o,console.log("Failed to sync Short Description")})}addAnEventListener(window,"message",iFrameListener),jQuery(document).ready(function(e){e(".notice .wc-facebook-manage-connection").click(function(e){e.preventDefault(),facebookConfig()}),e("#woocommerce-facebook-settings-sync-products").click(function(e){e.preventDefault(),sync_confirm()})});
changelog.txt CHANGED
@@ -1,5 +1,14 @@
1
  *** Facebook for WooCommerce Changelog ***
2
 
 
 
 
 
 
 
 
 
 
3
  2020.05.04 - version 1.11.2
4
  * Misc - Add support for WooCommerce 4.1
5
 
1
  *** Facebook for WooCommerce Changelog ***
2
 
3
+ 2020.05.20 - version 1.11.3
4
+ * Tweak - Write product feed to a temporary file and rename it when done, to prevent Facebook from downloading an incomplete feed file
5
+ * Tweak - Hide Facebook options for virtual products and virtual variations
6
+ * Tweak - Do not allow merchant to bulk enable sync for virtual products
7
+ * Tweak - On upgrade, automatically disable sync for virtual products and virtual variations
8
+ * Tweak - When using checkboxes for tags, make sure the modal is displayed when trying to enable sync for a product with an excluded tag
9
+ * Fix - Prevent tracking of a duplicated purchase event in some circumstances such as when the customer reloads the "Thank You" page after completing an order
10
+ * Fix - Fix a JavaScript issue that was causing a notice to be displayed when bulk editing product variations
11
+
12
  2020.05.04 - version 1.11.2
13
  * Misc - Add support for WooCommerce 4.1
14
 
class-wc-facebookcommerce.php CHANGED
@@ -9,6 +9,7 @@
9
  */
10
 
11
  use SkyVerge\WooCommerce\Facebook\Lifecycle;
 
12
  use SkyVerge\WooCommerce\PluginFramework\v5_5_4 as Framework;
13
 
14
  if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
@@ -19,7 +20,7 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
19
 
20
 
21
  /** @var string the plugin version */
22
- const VERSION = '1.11.2';
23
 
24
  /** @var string for backwards compatibility TODO: remove this in v2.0.0 {CW 2020-02-06} */
25
  const PLUGIN_VERSION = self::VERSION;
@@ -49,6 +50,9 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
49
  /** @var \SkyVerge\WooCommerce\Facebook\Products\Feed product feed handler */
50
  private $product_feed;
51
 
 
 
 
52
 
53
  /**
54
  * Constructs the plugin.
@@ -104,6 +108,14 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
104
 
105
  $this->integrations = new \SkyVerge\WooCommerce\Facebook\Integrations\Integrations( $this );
106
 
 
 
 
 
 
 
 
 
107
  }
108
  }
109
 
@@ -237,6 +249,17 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
237
  }
238
 
239
 
 
 
 
 
 
 
 
 
 
 
 
240
  /**
241
  * Gets the integration instance.
242
  *
@@ -303,7 +326,7 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
303
  */
304
  public function get_support_url() {
305
 
306
- return 'https://woocommerce.com/my-account/tickets/';
307
  }
308
 
309
 
9
  */
10
 
11
  use SkyVerge\WooCommerce\Facebook\Lifecycle;
12
+ use SkyVerge\WooCommerce\Facebook\Utilities\Background_Disable_Virtual_Products_Sync;
13
  use SkyVerge\WooCommerce\PluginFramework\v5_5_4 as Framework;
14
 
15
  if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
20
 
21
 
22
  /** @var string the plugin version */
23
+ const VERSION = '1.11.3';
24
 
25
  /** @var string for backwards compatibility TODO: remove this in v2.0.0 {CW 2020-02-06} */
26
  const PLUGIN_VERSION = self::VERSION;
50
  /** @var \SkyVerge\WooCommerce\Facebook\Products\Feed product feed handler */
51
  private $product_feed;
52
 
53
+ /** @var Background_Disable_Virtual_Products_Sync instance */
54
+ protected $background_disable_virtual_products_sync;
55
+
56
 
57
  /**
58
  * Constructs the plugin.
108
 
109
  $this->integrations = new \SkyVerge\WooCommerce\Facebook\Integrations\Integrations( $this );
110
 
111
+ if ( 'yes' !== get_option( 'wc_facebook_sync_virtual_products_disabled', 'no' ) ) {
112
+
113
+ require_once __DIR__ . '/vendor/skyverge/wc-plugin-framework/woocommerce/utilities/class-sv-wp-async-request.php';
114
+ require_once __DIR__ . '/vendor/skyverge/wc-plugin-framework/woocommerce/utilities/class-sv-wp-background-job-handler.php';
115
+ require_once __DIR__ . '/includes/Utilities/Background_Disable_Virtual_Products_Sync.php';
116
+
117
+ $this->background_disable_virtual_products_sync = new Background_Disable_Virtual_Products_Sync();
118
+ }
119
  }
120
  }
121
 
249
  }
250
 
251
 
252
+ /**
253
+ * Gets the background disable virtual products sync handler instance.
254
+ *
255
+ * @since 1.11.3-dev.2
256
+ */
257
+ public function get_background_disable_virtual_products_sync_instance() {
258
+
259
+ return $this->background_disable_virtual_products_sync;
260
+ }
261
+
262
+
263
  /**
264
  * Gets the integration instance.
265
  *
326
  */
327
  public function get_support_url() {
328
 
329
+ return 'https://wordpress.org/support/plugin/facebook-for-woocommerce/';
330
  }
331
 
332
 
facebook-commerce-events-tracker.php CHANGED
@@ -65,8 +65,8 @@ if ( ! class_exists( 'WC_Facebookcommerce_EventsTracker' ) ) :
65
  // InitiateCheckout events
66
  add_action( 'woocommerce_after_checkout_form', [ $this, 'inject_initiate_checkout_event' ] );
67
  // Purchase and Subscribe events
68
- add_action( 'woocommerce_thankyou', [ $this, 'inject_purchase_event' ], 40 );
69
- add_action( 'woocommerce_payment_complete', [ $this, 'inject_purchase_event' ], 40 );
70
 
71
  // TODO move this in some 3rd party plugin integrations handler at some point {FN 2020-03-20}
72
  add_action( 'wpcf7_contact_form', [ $this, 'inject_lead_event_hook' ], self::FB_PRIORITY_LOW );
@@ -481,7 +481,30 @@ if ( ! class_exists( 'WC_Facebookcommerce_EventsTracker' ) ) :
481
  return;
482
  }
483
 
484
- $order = wc_get_order( $order_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  $content_type = 'product';
486
  $num_items = 0;
487
  $contents = [];
@@ -518,6 +541,10 @@ if ( ! class_exists( 'WC_Facebookcommerce_EventsTracker' ) ) :
518
  ] );
519
 
520
  $this->inject_subscribe_event( $order_id );
 
 
 
 
521
  }
522
 
523
 
65
  // InitiateCheckout events
66
  add_action( 'woocommerce_after_checkout_form', [ $this, 'inject_initiate_checkout_event' ] );
67
  // Purchase and Subscribe events
68
+ add_action( 'woocommerce_checkout_update_order_meta', [ $this, 'inject_purchase_event' ] );
69
+ add_action( 'woocommerce_thankyou', [ $this, 'inject_purchase_event' ], 40 );
70
 
71
  // TODO move this in some 3rd party plugin integrations handler at some point {FN 2020-03-20}
72
  add_action( 'wpcf7_contact_form', [ $this, 'inject_lead_event_hook' ], self::FB_PRIORITY_LOW );
481
  return;
482
  }
483
 
484
+ $order = wc_get_order( $order_id );
485
+
486
+ if ( ! $order ) {
487
+ return;
488
+ }
489
+
490
+ // use an order meta to ensure an order is tracked with any payment method, also when the order is placed through AJAX
491
+ $order_placed_meta = '_wc_' . facebook_for_woocommerce()->get_id() . '_order_placed';
492
+
493
+ // use an order meta to ensure a Purchase event is not tracked multiple times
494
+ $purchase_tracked_meta = '_wc_' . facebook_for_woocommerce()->get_id() . '_purchase_tracked';
495
+
496
+ // when saving the order meta data: add a flag to mark the order tracked
497
+ if ( 'woocommerce_checkout_update_order_meta' === current_action() ) {
498
+ $order->update_meta_data( $order_placed_meta, 'yes' );
499
+ $order->save_meta_data();
500
+ return;
501
+ }
502
+
503
+ // bail if by the time we are on the thank you page the meta has not been set or we already tracked a Purchase event
504
+ if ( 'yes' !== $order->get_meta( $order_placed_meta ) || 'yes' === $order->get_meta( $purchase_tracked_meta ) ) {
505
+ return;
506
+ }
507
+
508
  $content_type = 'product';
509
  $num_items = 0;
510
  $contents = [];
541
  ] );
542
 
543
  $this->inject_subscribe_event( $order_id );
544
+
545
+ // mark the order as tracked
546
+ $order->update_meta_data( $purchase_tracked_meta, 'yes' );
547
+ $order->save_meta_data();
548
  }
549
 
550
 
facebook-commerce.php CHANGED
@@ -810,7 +810,7 @@ class WC_Facebookcommerce_Integration extends WC_Integration {
810
  }
811
 
812
  // phpcs:ignore WordPress.Security.NonceVerification.Missing
813
- $sync_enabled = ! empty( $_POST['fb_sync_enabled'] );
814
  $is_visible = ! empty( $_POST[ Products::VISIBILITY_META_KEY ] );
815
 
816
  if ( ! $product->is_type( 'variable' ) ) {
810
  }
811
 
812
  // phpcs:ignore WordPress.Security.NonceVerification.Missing
813
+ $sync_enabled = ! $product->is_virtual() && ! empty( $_POST['fb_sync_enabled'] );
814
  $is_visible = ! empty( $_POST[ Products::VISIBILITY_META_KEY ] );
815
 
816
  if ( ! $product->is_type( 'variable' ) ) {
facebook-for-woocommerce.php CHANGED
@@ -10,10 +10,10 @@
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: 1.11.2
14
  * Text Domain: facebook-for-woocommerce
15
  * WC requires at least: 3.5.0
16
- * WC tested up to: 4.1.0
17
  *
18
  * @package FacebookCommerce
19
  */
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: 1.11.3
14
  * Text Domain: facebook-for-woocommerce
15
  * WC requires at least: 3.5.0
16
+ * WC tested up to: 4.1.1
17
  *
18
  * @package FacebookCommerce
19
  */
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 1.11.2\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
- "POT-Creation-Date: 2020-05-05 05:51:17+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:146
17
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
18
  #. <a> tag, %4$s - </a> tag, %5$s - <a> tag, %6$s - </a> tag
19
  msgid ""
@@ -23,7 +23,7 @@ msgid ""
23
  "more%6$s."
24
  msgstr ""
25
 
26
- #: class-wc-facebookcommerce.php:156
27
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
28
  #. <a> tag, %4$s - </a> tag, %5$s - <a> tag, %6$s - </a> tag
29
  msgid ""
@@ -338,15 +338,15 @@ msgid ""
338
  "like to hide this product from your Facebook shop?"
339
  msgstr ""
340
 
341
- #: includes/AJAX.php:127 includes/AJAX.php:222
342
  msgid "Go to Settings"
343
  msgstr ""
344
 
345
- #: includes/AJAX.php:132 includes/AJAX.php:227 includes/AJAX.php:298
346
  msgid "Cancel"
347
  msgstr ""
348
 
349
- #: includes/AJAX.php:140
350
  #. translators: Placeholder %s - <br/> tag
351
  msgid ""
352
  "This product belongs to a category or tag that is excluded from the "
@@ -355,21 +355,21 @@ msgid ""
355
  "or click Cancel and update the product's category / tag assignments."
356
  msgstr ""
357
 
358
- #: includes/AJAX.php:181
359
  msgid "Hide Products"
360
  msgstr ""
361
 
362
- #: includes/AJAX.php:185
363
  msgid "Do Not Hide Products"
364
  msgstr ""
365
 
366
- #: includes/AJAX.php:191
367
  msgid ""
368
  "The selected products will no longer be updated in your Facebook catalog. "
369
  "Would you like to hide these products from your Facebook shop?"
370
  msgstr ""
371
 
372
- #: includes/AJAX.php:233
373
  msgid ""
374
  "One or more of the selected products belongs to a category or tag that is "
375
  "excluded from the Facebook catalog sync. To sync these products to "
@@ -377,15 +377,15 @@ msgid ""
377
  "settings."
378
  msgstr ""
379
 
380
- #: includes/AJAX.php:286
381
  msgid "Exclude Products"
382
  msgstr ""
383
 
384
- #: includes/AJAX.php:292
385
  msgid "Exclude Products and Hide in Facebook"
386
  msgstr ""
387
 
388
- #: includes/AJAX.php:306
389
  #. translators: Placeholder %s - <br/> tags
390
  msgid ""
391
  "The categories and/or tags that you have selected to exclude from sync "
@@ -394,7 +394,7 @@ msgid ""
394
  "category / tag exclusion settings, click Cancel."
395
  msgstr ""
396
 
397
- #: includes/Admin.php:121
398
  #. translators: Placeholders %1$s - opening <strong> html tag, %2$s closing
399
  #. </strong> html tag, {count} number of remaining items
400
  msgid "%1$sProgress:%2$s {count} item remaining."
@@ -402,16 +402,16 @@ msgid_plural "%1$sProgress:%2$s {count} items remaining."
402
  msgstr[0] ""
403
  msgstr[1] ""
404
 
405
- #: includes/Admin.php:129
406
  #. translators: Placeholders %s - html code for a spinner icon
407
  msgid "Your products will now be resynced to Facebook, this may take some time."
408
  msgstr ""
409
 
410
- #: includes/Admin.php:130
411
  msgid "Launch Test?"
412
  msgstr ""
413
 
414
- #: includes/Admin.php:131
415
  msgid ""
416
  "Facebook for WooCommerce automatically syncs your products on "
417
  "create/update. Are you sure you want to force product resync?\n"
@@ -421,108 +421,108 @@ msgid ""
421
  "did not sync."
422
  msgstr ""
423
 
424
- #: includes/Admin.php:132
425
  msgid "Syncing... Keep this browser open until sync is complete. %s"
426
  msgstr ""
427
 
428
- #: includes/Admin.php:136
429
  #. translators: Placeholders %1$s - opening <strong> html tag, %2$s closing
430
  #. </strong> html tag
431
  msgid "%1$sStatus:%2$s Test Pass."
432
  msgstr ""
433
 
434
- #: includes/Admin.php:138
435
  #. translators: Placeholders %1$s - opening <strong> html tag, %2$s closing
436
  #. </strong> html tag
437
  msgid "%1$sStatus:%2$s Integration test in progress..."
438
  msgstr ""
439
 
440
- #: includes/Admin.php:140
441
  #. translators: Placeholders %1$s - opening <strong> html tag, %2$s closing
442
  #. </strong> html tag
443
  msgid "%1$sStatus:%2$s Test Fail."
444
  msgstr ""
445
 
446
- #: includes/Admin.php:141
447
  msgid "There was an error trying to sync the products to Facebook."
448
  msgstr ""
449
 
450
- #: includes/Admin.php:142
451
  msgid ""
452
  "Something went wrong while uploading the product information, please try "
453
  "again."
454
  msgstr ""
455
 
456
- #: includes/Admin.php:162
457
  msgid "FB Sync Enabled"
458
  msgstr ""
459
 
460
- #: includes/Admin.php:186
461
  msgid "Enabled"
462
  msgstr ""
463
 
464
- #: includes/Admin.php:188
465
  msgid "Disabled"
466
  msgstr ""
467
 
468
- #: includes/Admin.php:206
469
  #. translators: Points to a product that was never synced with Facebook
470
  msgid "Never synced with Facebook."
471
  msgstr ""
472
 
473
- #: includes/Admin.php:218
474
  #. translators: Action to hide a product (currently synced with Facebook) from
475
  #. the Facebook catalog
476
  msgid "Hide from Facebook catalog. Currently synced with Facebook."
477
  msgstr ""
478
 
479
- #: includes/Admin.php:220
480
  #. translators: Action to publish a product (currently synced with Facebook) in
481
  #. the Facebook catalog
482
  msgid "Publish in Facebook catalog. Currently synced with Facebook."
483
  msgstr ""
484
 
485
- #: includes/Admin.php:223
486
  #. translators: Action to hide a product (currently not synced with Facebook)
487
  #. from the Facebook catalog
488
  msgid "Hide from Facebook catalog. Not synced with Facebook."
489
  msgstr ""
490
 
491
- #: includes/Admin.php:225
492
  #. translators: Action to publish a product (currently not synced with
493
  #. Facebook) in the Facebook catalog
494
  msgid "Publish in Facebook catalog. Not synced with Facebook."
495
  msgstr ""
496
 
497
- #: includes/Admin.php:236
498
  msgid "Show"
499
  msgstr ""
500
 
501
- #: includes/Admin.php:244
502
  msgid "Hide"
503
  msgstr ""
504
 
505
- #: includes/Admin.php:272
506
  msgid "Filter by Facebook sync setting"
507
  msgstr ""
508
 
509
- #: includes/Admin.php:273
510
  msgid "Facebook sync enabled"
511
  msgstr ""
512
 
513
- #: includes/Admin.php:274
514
  msgid "Facebook sync disabled"
515
  msgstr ""
516
 
517
- #: includes/Admin.php:458 includes/Admin.php:692 includes/Admin.php:784
518
  msgid "Include in Facebook sync"
519
  msgstr ""
520
 
521
- #: includes/Admin.php:459
522
  msgid "Exclude from Facebook sync"
523
  msgstr ""
524
 
525
- #: includes/Admin.php:546
526
  #. translators: Placeholders: %1$s - Facebook for Woocommerce, %2$s - opening
527
  #. HTML <a> link tag, %3$s - closing HTML </a> link tag
528
  msgid ""
@@ -531,7 +531,7 @@ msgid ""
531
  "checkout URLs on Facebook%3$s."
532
  msgstr ""
533
 
534
- #: includes/Admin.php:579
535
  #. translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing
536
  #. HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a>
537
  #. tag
@@ -541,11 +541,11 @@ msgid ""
541
  "to update the catalog with any changes you've made. %3$sLearn more%4$s"
542
  msgstr ""
543
 
544
- #: includes/Admin.php:586
545
  msgid "Don't show this notice again"
546
  msgstr ""
547
 
548
- #: includes/Admin.php:632
549
  #. translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing
550
  #. HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a>
551
  #. tag
@@ -556,61 +556,81 @@ msgid ""
556
  "%3$sLearn more%4$s"
557
  msgstr ""
558
 
559
- #: includes/Admin.php:698 includes/Admin.php:793
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
560
  msgid "Facebook Description"
561
  msgstr ""
562
 
563
- #: includes/Admin.php:700 includes/Admin.php:795
564
  msgid ""
565
  "Custom (plain-text only) description for product on Facebook. If blank, "
566
  "product description will be used. If product description is blank, "
567
  "shortname will be used."
568
  msgstr ""
569
 
570
- #: includes/Admin.php:709 includes/Admin.php:806
571
  msgid "Facebook Product Image"
572
  msgstr ""
573
 
574
- #: includes/Admin.php:711 includes/Admin.php:808
575
  msgid ""
576
  "Choose the product image that should be synced to the Facebook catalog for "
577
  "this product. If using a custom image, please enter an absolute URL (e.g. "
578
  "https://domain.com/image.jpg)."
579
  msgstr ""
580
 
581
- #: includes/Admin.php:713
582
  msgid "Use WooCommerce image"
583
  msgstr ""
584
 
585
- #: includes/Admin.php:714 includes/Admin.php:812
586
  msgid "Use custom image"
587
  msgstr ""
588
 
589
- #: includes/Admin.php:723 includes/Admin.php:822
590
  msgid "Custom Image URL"
591
  msgstr ""
592
 
593
- #: includes/Admin.php:732 includes/Admin.php:833
594
  #. translators: Placeholders %1$s - WC currency symbol
595
  msgid "Facebook Price (%1$s)"
596
  msgstr ""
597
 
598
- #: includes/Admin.php:736 includes/Admin.php:837
599
  msgid ""
600
  "Custom price for product on Facebook. Please enter in monetary decimal (.) "
601
  "format without thousand separators and currency symbols. If blank, product "
602
  "price will be used."
603
  msgstr ""
604
 
605
- #: includes/Admin.php:810
606
  msgid "Use variation image"
607
  msgstr ""
608
 
609
- #: includes/Admin.php:811
610
  msgid "Use parent image"
611
  msgstr ""
612
 
613
- #: includes/Admin.php:942
614
  msgid "Close modal panel"
615
  msgstr ""
616
 
@@ -630,14 +650,22 @@ msgstr ""
630
  msgid "Dismiss"
631
  msgstr ""
632
 
633
- #: includes/fbproductfeed.php:432
634
  msgid "Could not create product catalog feed directory"
635
  msgstr ""
636
 
637
- #: includes/fbproductfeed.php:498
 
 
 
 
638
  msgid "Could not open the product catalog feed file for writing"
639
  msgstr ""
640
 
 
 
 
 
641
  #: includes/fbwpml.php:114
642
  msgid "Facebook Visibility"
643
  msgstr ""
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 1.11.3\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
+ "POT-Creation-Date: 2020-05-21 03:03:55+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:158
17
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
18
  #. <a> tag, %4$s - </a> tag, %5$s - <a> tag, %6$s - </a> tag
19
  msgid ""
23
  "more%6$s."
24
  msgstr ""
25
 
26
+ #: class-wc-facebookcommerce.php:168
27
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
28
  #. <a> tag, %4$s - </a> tag, %5$s - <a> tag, %6$s - </a> tag
29
  msgid ""
338
  "like to hide this product from your Facebook shop?"
339
  msgstr ""
340
 
341
+ #: includes/AJAX.php:131 includes/AJAX.php:226
342
  msgid "Go to Settings"
343
  msgstr ""
344
 
345
+ #: includes/AJAX.php:136 includes/AJAX.php:231 includes/AJAX.php:302
346
  msgid "Cancel"
347
  msgstr ""
348
 
349
+ #: includes/AJAX.php:144
350
  #. translators: Placeholder %s - <br/> tag
351
  msgid ""
352
  "This product belongs to a category or tag that is excluded from the "
355
  "or click Cancel and update the product's category / tag assignments."
356
  msgstr ""
357
 
358
+ #: includes/AJAX.php:185
359
  msgid "Hide Products"
360
  msgstr ""
361
 
362
+ #: includes/AJAX.php:189
363
  msgid "Do Not Hide Products"
364
  msgstr ""
365
 
366
+ #: includes/AJAX.php:195
367
  msgid ""
368
  "The selected products will no longer be updated in your Facebook catalog. "
369
  "Would you like to hide these products from your Facebook shop?"
370
  msgstr ""
371
 
372
+ #: includes/AJAX.php:237
373
  msgid ""
374
  "One or more of the selected products belongs to a category or tag that is "
375
  "excluded from the Facebook catalog sync. To sync these products to "
377
  "settings."
378
  msgstr ""
379
 
380
+ #: includes/AJAX.php:290
381
  msgid "Exclude Products"
382
  msgstr ""
383
 
384
+ #: includes/AJAX.php:296
385
  msgid "Exclude Products and Hide in Facebook"
386
  msgstr ""
387
 
388
+ #: includes/AJAX.php:310
389
  #. translators: Placeholder %s - <br/> tags
390
  msgid ""
391
  "The categories and/or tags that you have selected to exclude from sync "
394
  "category / tag exclusion settings, click Cancel."
395
  msgstr ""
396
 
397
+ #: includes/Admin.php:126
398
  #. translators: Placeholders %1$s - opening <strong> html tag, %2$s closing
399
  #. </strong> html tag, {count} number of remaining items
400
  msgid "%1$sProgress:%2$s {count} item remaining."
402
  msgstr[0] ""
403
  msgstr[1] ""
404
 
405
+ #: includes/Admin.php:134
406
  #. translators: Placeholders %s - html code for a spinner icon
407
  msgid "Your products will now be resynced to Facebook, this may take some time."
408
  msgstr ""
409
 
410
+ #: includes/Admin.php:135
411
  msgid "Launch Test?"
412
  msgstr ""
413
 
414
+ #: includes/Admin.php:136
415
  msgid ""
416
  "Facebook for WooCommerce automatically syncs your products on "
417
  "create/update. Are you sure you want to force product resync?\n"
421
  "did not sync."
422
  msgstr ""
423
 
424
+ #: includes/Admin.php:137
425
  msgid "Syncing... Keep this browser open until sync is complete. %s"
426
  msgstr ""
427
 
428
+ #: includes/Admin.php:141
429
  #. translators: Placeholders %1$s - opening <strong> html tag, %2$s closing
430
  #. </strong> html tag
431
  msgid "%1$sStatus:%2$s Test Pass."
432
  msgstr ""
433
 
434
+ #: includes/Admin.php:143
435
  #. translators: Placeholders %1$s - opening <strong> html tag, %2$s closing
436
  #. </strong> html tag
437
  msgid "%1$sStatus:%2$s Integration test in progress..."
438
  msgstr ""
439
 
440
+ #: includes/Admin.php:145
441
  #. translators: Placeholders %1$s - opening <strong> html tag, %2$s closing
442
  #. </strong> html tag
443
  msgid "%1$sStatus:%2$s Test Fail."
444
  msgstr ""
445
 
446
+ #: includes/Admin.php:146
447
  msgid "There was an error trying to sync the products to Facebook."
448
  msgstr ""
449
 
450
+ #: includes/Admin.php:147
451
  msgid ""
452
  "Something went wrong while uploading the product information, please try "
453
  "again."
454
  msgstr ""
455
 
456
+ #: includes/Admin.php:167
457
  msgid "FB Sync Enabled"
458
  msgstr ""
459
 
460
+ #: includes/Admin.php:191
461
  msgid "Enabled"
462
  msgstr ""
463
 
464
+ #: includes/Admin.php:193
465
  msgid "Disabled"
466
  msgstr ""
467
 
468
+ #: includes/Admin.php:211
469
  #. translators: Points to a product that was never synced with Facebook
470
  msgid "Never synced with Facebook."
471
  msgstr ""
472
 
473
+ #: includes/Admin.php:223
474
  #. translators: Action to hide a product (currently synced with Facebook) from
475
  #. the Facebook catalog
476
  msgid "Hide from Facebook catalog. Currently synced with Facebook."
477
  msgstr ""
478
 
479
+ #: includes/Admin.php:225
480
  #. translators: Action to publish a product (currently synced with Facebook) in
481
  #. the Facebook catalog
482
  msgid "Publish in Facebook catalog. Currently synced with Facebook."
483
  msgstr ""
484
 
485
+ #: includes/Admin.php:228
486
  #. translators: Action to hide a product (currently not synced with Facebook)
487
  #. from the Facebook catalog
488
  msgid "Hide from Facebook catalog. Not synced with Facebook."
489
  msgstr ""
490
 
491
+ #: includes/Admin.php:230
492
  #. translators: Action to publish a product (currently not synced with
493
  #. Facebook) in the Facebook catalog
494
  msgid "Publish in Facebook catalog. Not synced with Facebook."
495
  msgstr ""
496
 
497
+ #: includes/Admin.php:241
498
  msgid "Show"
499
  msgstr ""
500
 
501
+ #: includes/Admin.php:249
502
  msgid "Hide"
503
  msgstr ""
504
 
505
+ #: includes/Admin.php:277
506
  msgid "Filter by Facebook sync setting"
507
  msgstr ""
508
 
509
+ #: includes/Admin.php:278
510
  msgid "Facebook sync enabled"
511
  msgstr ""
512
 
513
+ #: includes/Admin.php:279
514
  msgid "Facebook sync disabled"
515
  msgstr ""
516
 
517
+ #: includes/Admin.php:463 includes/Admin.php:793 includes/Admin.php:885
518
  msgid "Include in Facebook sync"
519
  msgstr ""
520
 
521
+ #: includes/Admin.php:464
522
  msgid "Exclude from Facebook sync"
523
  msgstr ""
524
 
525
+ #: includes/Admin.php:591
526
  #. translators: Placeholders: %1$s - Facebook for Woocommerce, %2$s - opening
527
  #. HTML <a> link tag, %3$s - closing HTML </a> link tag
528
  msgid ""
531
  "checkout URLs on Facebook%3$s."
532
  msgstr ""
533
 
534
+ #: includes/Admin.php:624
535
  #. translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing
536
  #. HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a>
537
  #. tag
541
  "to update the catalog with any changes you've made. %3$sLearn more%4$s"
542
  msgstr ""
543
 
544
+ #: includes/Admin.php:631
545
  msgid "Don't show this notice again"
546
  msgstr ""
547
 
548
+ #: includes/Admin.php:677
549
  #. translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing
550
  #. HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a>
551
  #. tag
556
  "%3$sLearn more%4$s"
557
  msgstr ""
558
 
559
+ #: includes/Admin.php:705
560
+ #. translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing
561
+ #. HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a>
562
+ #. tag
563
+ msgid ""
564
+ "%1$sHeads up!%2$s Facebook does not support selling virtual products, so we "
565
+ "can't include virtual products in your catalog sync. %3$sClick here to read "
566
+ "more about Facebook's policy%4$s."
567
+ msgstr ""
568
+
569
+ #: includes/Admin.php:733
570
+ #. translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing
571
+ #. HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a>
572
+ #. tag
573
+ msgid ""
574
+ "%1$sHeads up!%2$s Facebook does not support selling virtual products, so we "
575
+ "have removed any previously synced virtual products from the catalog sync "
576
+ "going forward. %3$sClick here to read more about Facebook's policy%4$s."
577
+ msgstr ""
578
+
579
+ #: includes/Admin.php:799 includes/Admin.php:894
580
  msgid "Facebook Description"
581
  msgstr ""
582
 
583
+ #: includes/Admin.php:801 includes/Admin.php:896
584
  msgid ""
585
  "Custom (plain-text only) description for product on Facebook. If blank, "
586
  "product description will be used. If product description is blank, "
587
  "shortname will be used."
588
  msgstr ""
589
 
590
+ #: includes/Admin.php:810 includes/Admin.php:907
591
  msgid "Facebook Product Image"
592
  msgstr ""
593
 
594
+ #: includes/Admin.php:812 includes/Admin.php:909
595
  msgid ""
596
  "Choose the product image that should be synced to the Facebook catalog for "
597
  "this product. If using a custom image, please enter an absolute URL (e.g. "
598
  "https://domain.com/image.jpg)."
599
  msgstr ""
600
 
601
+ #: includes/Admin.php:814
602
  msgid "Use WooCommerce image"
603
  msgstr ""
604
 
605
+ #: includes/Admin.php:815 includes/Admin.php:913
606
  msgid "Use custom image"
607
  msgstr ""
608
 
609
+ #: includes/Admin.php:824 includes/Admin.php:923
610
  msgid "Custom Image URL"
611
  msgstr ""
612
 
613
+ #: includes/Admin.php:833 includes/Admin.php:934
614
  #. translators: Placeholders %1$s - WC currency symbol
615
  msgid "Facebook Price (%1$s)"
616
  msgstr ""
617
 
618
+ #: includes/Admin.php:837 includes/Admin.php:938
619
  msgid ""
620
  "Custom price for product on Facebook. Please enter in monetary decimal (.) "
621
  "format without thousand separators and currency symbols. If blank, product "
622
  "price will be used."
623
  msgstr ""
624
 
625
+ #: includes/Admin.php:911
626
  msgid "Use variation image"
627
  msgstr ""
628
 
629
+ #: includes/Admin.php:912
630
  msgid "Use parent image"
631
  msgstr ""
632
 
633
+ #: includes/Admin.php:1043
634
  msgid "Close modal panel"
635
  msgstr ""
636
 
650
  msgid "Dismiss"
651
  msgstr ""
652
 
653
+ #: includes/fbproductfeed.php:474
654
  msgid "Could not create product catalog feed directory"
655
  msgstr ""
656
 
657
+ #: includes/fbproductfeed.php:540
658
+ msgid "Could not open the product catalog temporary feed file for writing"
659
+ msgstr ""
660
+
661
+ #: includes/fbproductfeed.php:547
662
  msgid "Could not open the product catalog feed file for writing"
663
  msgstr ""
664
 
665
+ #: includes/fbproductfeed.php:594
666
+ msgid "Could not rename the product catalog feed file"
667
+ msgstr ""
668
+
669
  #: includes/fbwpml.php:114
670
  msgid "Facebook Visibility"
671
  msgstr ""
includes/AJAX.php CHANGED
@@ -103,9 +103,13 @@ class AJAX {
103
 
104
  $product_tag_ids = [];
105
 
106
- foreach ( $product_tags as $product_tag_name ) {
107
 
108
- if ( $term = get_term_by( 'name', $product_tag_name, 'product_tag' ) ) {
 
 
 
 
109
 
110
  $product_tag_ids[] = $term->term_id;
111
  }
103
 
104
  $product_tag_ids = [];
105
 
106
+ foreach ( $product_tags as $product_tag_name_or_id ) {
107
 
108
+ if ( $term = get_term_by( 'name', $product_tag_name_or_id, 'product_tag' ) ) {
109
+
110
+ $product_tag_ids[] = $term->term_id;
111
+
112
+ } elseif ( $term = get_term( (int) $product_tag_name_or_id, 'product_tag' ) ) {
113
 
114
  $product_tag_ids[] = $term->term_id;
115
  }
includes/Admin.php CHANGED
@@ -51,6 +51,11 @@ class Admin {
51
  add_action( 'admin_notices', [ $this, 'add_product_sync_delay_notice' ] );
52
  // add admin notice to inform that the catalog visibility setting was removed
53
  add_action( 'admin_notices', [ $this, 'add_catalog_visibility_settings_removed_notice' ] );
 
 
 
 
 
54
  // handle dismissal of special notices
55
  add_action( 'wc_' . facebook_for_woocommerce()->get_id(). '_dismiss_notice', [ $this, 'handle_dismiss_notice' ], 10, 2 );
56
 
@@ -493,14 +498,54 @@ class Admin {
493
 
494
  if ( ! empty( $product_ids ) ) {
495
 
 
 
 
496
  foreach ( $product_ids as $product_id ) {
497
 
498
  if ( $product = wc_get_product( $product_id ) ) {
499
 
500
- $products[] = $product;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501
  }
502
  }
503
 
 
 
 
 
 
 
504
  if ( 'facebook_include' === $action ) {
505
 
506
  Products::enable_sync_for_products( $products );
@@ -642,6 +687,62 @@ class Admin {
642
  }
643
 
644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
645
  /**
646
  * Adds a new tab to the Product edit page.
647
  *
@@ -657,7 +758,7 @@ class Admin {
657
  $tabs['fb_commerce_tab'] = [
658
  'label' => __( 'Facebook', 'facebook-for-woocommerce' ),
659
  'target' => 'facebook_options',
660
- 'class' => [ 'show_if_simple' ],
661
  ];
662
 
663
  return $tabs;
@@ -784,7 +885,7 @@ class Admin {
784
  'label' => __( 'Include in Facebook sync', 'facebook-for-woocommerce' ),
785
  'value' => wc_bool_to_string( 'no' !== $sync_enabled ),
786
  'class' => 'checkbox js-variable-fb-sync-toggle',
787
- 'wrapper_class' => 'fb-sync-enabled-field',
788
  ] );
789
 
790
  woocommerce_wp_textarea_input( [
@@ -797,7 +898,7 @@ class Admin {
797
  'rows' => 5,
798
  'value' => $description,
799
  'class' => 'enable-if-sync-enabled',
800
- 'wrapper_class' => 'form-row form-row-full',
801
  ] );
802
 
803
  woocommerce_wp_radio( [
@@ -813,7 +914,7 @@ class Admin {
813
  ],
814
  'value' => $image_source ?: Products::PRODUCT_IMAGE_SOURCE_PRODUCT,
815
  'class' => 'enable-if-sync-enabled js-fb-product-image-source',
816
- 'wrapper_class' => 'fb-product-image-source-field',
817
  ] );
818
 
819
  woocommerce_wp_text_input( [
@@ -822,7 +923,7 @@ class Admin {
822
  'label' => __( 'Custom Image URL', 'facebook-for-woocommerce' ),
823
  'value' => $image_url,
824
  'class' => sprintf( 'enable-if-sync-enabled product-image-source-field show-if-product-image-source-%s', Products::PRODUCT_IMAGE_SOURCE_CUSTOM ),
825
- 'wrapper_class' => 'form-row form-row-full',
826
  ] );
827
 
828
  woocommerce_wp_text_input( [
@@ -837,7 +938,7 @@ class Admin {
837
  'description' => __( 'Custom price for product on Facebook. Please enter in monetary decimal (.) format without thousand separators and currency symbols. If blank, product price will be used.', 'facebook-for-woocommerce' ),
838
  'value' => wc_format_decimal( $price ),
839
  'class' => 'enable-if-sync-enabled',
840
- 'wrapper_class' => 'form-row form-full',
841
  ] );
842
  }
843
 
@@ -885,7 +986,7 @@ class Admin {
885
  }
886
 
887
  // phpcs:disable WordPress.Security.NonceVerification.Missing
888
- if ( isset( $_POST['variable_fb_sync_enabled'][ $index ] ) && 'yes' === $_POST['variable_fb_sync_enabled'][ $index ] ) {
889
 
890
  Products::enable_sync_for_products( [ $variation ] );
891
 
51
  add_action( 'admin_notices', [ $this, 'add_product_sync_delay_notice' ] );
52
  // add admin notice to inform that the catalog visibility setting was removed
53
  add_action( 'admin_notices', [ $this, 'add_catalog_visibility_settings_removed_notice' ] );
54
+ // add admin notice if the user attempted to enable sync for virtual products using the bulk action
55
+ add_action( 'admin_notices', [ $this, 'add_enabling_virtual_products_sync_notice' ] );
56
+ // add admin notice to inform sync has been automatically disabled for virtual products
57
+ add_action( 'admin_notices', [ $this, 'add_disabled_virtual_products_sync_notice' ] );
58
+
59
  // handle dismissal of special notices
60
  add_action( 'wc_' . facebook_for_woocommerce()->get_id(). '_dismiss_notice', [ $this, 'handle_dismiss_notice' ], 10, 2 );
61
 
498
 
499
  if ( ! empty( $product_ids ) ) {
500
 
501
+ $is_enabling_sync_virtual_products = false;
502
+ $is_enabling_sync_virtual_variations = false;
503
+
504
  foreach ( $product_ids as $product_id ) {
505
 
506
  if ( $product = wc_get_product( $product_id ) ) {
507
 
508
+ if ( 'facebook_include' === $action ) {
509
+
510
+ if ( $product->is_virtual() ) {
511
+
512
+ $is_enabling_sync_virtual_products = true;
513
+
514
+ } else {
515
+
516
+ // products with virtual variations are also added to the list,
517
+ // because they may have non-virtual variations as well
518
+ $products[] = $product;
519
+
520
+ if ( $product->is_type( 'variable' ) ) {
521
+
522
+ // check if the product has virtual variations, to display notice
523
+ foreach ( $product->get_children() as $variation_id ) {
524
+
525
+ $variation = wc_get_product( $variation_id );
526
+
527
+ if ( $variation && $variation->is_virtual() ) {
528
+
529
+ $is_enabling_sync_virtual_variations = true;
530
+ break;
531
+ }
532
+ }
533
+ }
534
+ }
535
+ } else {
536
+
537
+ // add the product to the list of products to disable sync from
538
+ $products[] = $product;
539
+ }
540
  }
541
  }
542
 
543
+ // display notice if enabling sync for virtual products or variations
544
+ if ( $is_enabling_sync_virtual_products || $is_enabling_sync_virtual_variations ) {
545
+
546
+ $redirect = add_query_arg( [ 'enabling_virtual_products_sync' => 1 ], $redirect );
547
+ }
548
+
549
  if ( 'facebook_include' === $action ) {
550
 
551
  Products::enable_sync_for_products( $products );
687
  }
688
 
689
 
690
+ /**
691
+ * Prints a notice on products page to inform users that the virtual products selected for the Include bulk action will NOT have sync enabled.
692
+ *
693
+ * @internal
694
+ *
695
+ * @since 1.11.3-dev.2
696
+ */
697
+ public function add_enabling_virtual_products_sync_notice() {
698
+ global $current_screen;
699
+
700
+ if ( isset( $_GET['enabling_virtual_products_sync'] ) && isset( $current_screen->id ) && 'edit-product' === $current_screen->id ) {
701
+
702
+ facebook_for_woocommerce()->get_admin_notice_handler()->add_admin_notice(
703
+ sprintf(
704
+ /* translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a> tag */
705
+ esc_html__( '%1$sHeads up!%2$s Facebook does not support selling virtual products, so we can\'t include virtual products in your catalog sync. %3$sClick here to read more about Facebook\'s policy%4$s.', 'facebook-for-woocommerce' ),
706
+ '<strong>',
707
+ '</strong>',
708
+ '<a href="https://www.facebook.com/help/130910837313345" target="_blank">',
709
+ '</a>'
710
+ ),
711
+ 'wc-' . facebook_for_woocommerce()->get_id_dasherized() . '-enabling-virtual-products-sync',
712
+ [ 'notice_class' => 'notice-info' ]
713
+ );
714
+ }
715
+ }
716
+
717
+
718
+ /**
719
+ * Prints a notice to inform sync has been automatically disabled for virtual products.
720
+ *
721
+ * @internal
722
+ *
723
+ * @since 1.11.3-dev.2
724
+ */
725
+ public function add_disabled_virtual_products_sync_notice() {
726
+
727
+ if ( 'yes' === get_option( 'wc_facebook_sync_virtual_products_disabled', 'no' ) &&
728
+ 'yes' !== get_option( 'wc_facebook_sync_virtual_products_disabled_skipped', 'no' ) ) {
729
+
730
+ facebook_for_woocommerce()->get_admin_notice_handler()->add_admin_notice(
731
+ sprintf(
732
+ /* translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a> tag */
733
+ esc_html__( '%1$sHeads up!%2$s Facebook does not support selling virtual products, so we have removed any previously synced virtual products from the catalog sync going forward. %3$sClick here to read more about Facebook\'s policy%4$s.', 'facebook-for-woocommerce' ),
734
+ '<strong>',
735
+ '</strong>',
736
+ '<a href="https://www.facebook.com/help/130910837313345" target="_blank">',
737
+ '</a>'
738
+ ),
739
+ 'wc-' . facebook_for_woocommerce()->get_id_dasherized() . '-disabled-virtual-products-sync',
740
+ [ 'notice_class' => 'notice-info' ]
741
+ );
742
+ }
743
+ }
744
+
745
+
746
  /**
747
  * Adds a new tab to the Product edit page.
748
  *
758
  $tabs['fb_commerce_tab'] = [
759
  'label' => __( 'Facebook', 'facebook-for-woocommerce' ),
760
  'target' => 'facebook_options',
761
+ 'class' => [ 'show_if_simple', 'hide_if_virtual' ],
762
  ];
763
 
764
  return $tabs;
885
  'label' => __( 'Include in Facebook sync', 'facebook-for-woocommerce' ),
886
  'value' => wc_bool_to_string( 'no' !== $sync_enabled ),
887
  'class' => 'checkbox js-variable-fb-sync-toggle',
888
+ 'wrapper_class' => 'fb-sync-enabled-field hide_if_variation_virtual',
889
  ] );
890
 
891
  woocommerce_wp_textarea_input( [
898
  'rows' => 5,
899
  'value' => $description,
900
  'class' => 'enable-if-sync-enabled',
901
+ 'wrapper_class' => 'form-row form-row-full hide_if_variation_virtual',
902
  ] );
903
 
904
  woocommerce_wp_radio( [
914
  ],
915
  'value' => $image_source ?: Products::PRODUCT_IMAGE_SOURCE_PRODUCT,
916
  'class' => 'enable-if-sync-enabled js-fb-product-image-source',
917
+ 'wrapper_class' => 'fb-product-image-source-field hide_if_variation_virtual',
918
  ] );
919
 
920
  woocommerce_wp_text_input( [
923
  'label' => __( 'Custom Image URL', 'facebook-for-woocommerce' ),
924
  'value' => $image_url,
925
  'class' => sprintf( 'enable-if-sync-enabled product-image-source-field show-if-product-image-source-%s', Products::PRODUCT_IMAGE_SOURCE_CUSTOM ),
926
+ 'wrapper_class' => 'form-row form-row-full hide_if_variation_virtual',
927
  ] );
928
 
929
  woocommerce_wp_text_input( [
938
  'description' => __( 'Custom price for product on Facebook. Please enter in monetary decimal (.) format without thousand separators and currency symbols. If blank, product price will be used.', 'facebook-for-woocommerce' ),
939
  'value' => wc_format_decimal( $price ),
940
  'class' => 'enable-if-sync-enabled',
941
+ 'wrapper_class' => 'form-row form-full hide_if_variation_virtual',
942
  ] );
943
  }
944
 
986
  }
987
 
988
  // phpcs:disable WordPress.Security.NonceVerification.Missing
989
+ if ( ! $variation->is_virtual() && isset( $_POST['variable_fb_sync_enabled'][ $index ] ) && 'yes' === $_POST['variable_fb_sync_enabled'][ $index ] ) {
990
 
991
  Products::enable_sync_for_products( [ $variation ] );
992
 
includes/Lifecycle.php CHANGED
@@ -39,6 +39,7 @@ class Lifecycle extends Framework\Plugin\Lifecycle {
39
  '1.10.0',
40
  '1.10.1',
41
  '1.11.0',
 
42
  ];
43
  }
44
 
@@ -217,4 +218,20 @@ class Lifecycle extends Framework\Plugin\Lifecycle {
217
  }
218
 
219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  }
39
  '1.10.0',
40
  '1.10.1',
41
  '1.11.0',
42
+ '1.11.3',
43
  ];
44
  }
45
 
218
  }
219
 
220
 
221
+ /**
222
+ * Upgrades to version 1.11.3.
223
+ *
224
+ * @since 1.11.3-dev.2
225
+ */
226
+ protected function upgrade_to_1_11_3() {
227
+
228
+ if ( $handler = $this->get_plugin()->get_background_disable_virtual_products_sync_instance() ) {
229
+
230
+ // create_job() expects an non-empty array of attributes
231
+ $handler->create_job( [ 'created_at' => current_time( 'mysql' ) ] );
232
+ $handler->dispatch();
233
+ }
234
+ }
235
+
236
+
237
  }
includes/Products.php CHANGED
@@ -73,6 +73,12 @@ class Products {
73
 
74
  if ( $product_variation instanceof \WC_Product ) {
75
 
 
 
 
 
 
 
76
  $product_variation->update_meta_data( self::SYNC_ENABLED_META_KEY, $enabled );
77
  $product_variation->save_meta_data();
78
  }
73
 
74
  if ( $product_variation instanceof \WC_Product ) {
75
 
76
+ if ( $enabled && $product_variation->is_virtual() ) {
77
+
78
+ // never enable sync for virtual variations
79
+ continue;
80
+ }
81
+
82
  $product_variation->update_meta_data( self::SYNC_ENABLED_META_KEY, $enabled );
83
  $product_variation->save_meta_data();
84
  }
includes/Utilities/Background_Disable_Virtual_Products_Sync.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\Utilities;
12
+
13
+ defined( 'ABSPATH' ) or exit;
14
+
15
+ use SkyVerge\WooCommerce\PluginFramework\v5_5_4 as Framework;
16
+
17
+
18
+ /**
19
+ * Background job handler to exclude virtual products and virtual product variations from sync.
20
+ *
21
+ * @since 1.11.3-dev.2
22
+ */
23
+ class Background_Disable_Virtual_Products_Sync extends Framework\SV_WP_Background_Job_Handler {
24
+
25
+
26
+ /**
27
+ * Background job constructor.
28
+ *
29
+ * @since 1.11.3-dev.2
30
+ */
31
+ public function __construct() {
32
+
33
+ $this->prefix = 'wc_facebook';
34
+ $this->action = 'background_disable_virtual_products_sync';
35
+
36
+ parent::__construct();
37
+ }
38
+
39
+
40
+ /**
41
+ * Processes job.
42
+ *
43
+ * This job continues to update products and product variations meta data until we run out of memory
44
+ * or exceed the time limit. There is no list of items to loop over.
45
+ *
46
+ * @since 1.11.3-dev.2
47
+ *
48
+ * @param object $job
49
+ * @param int $items_per_batch number of items to process in a single request. Defaults to unlimited.
50
+ * @return object
51
+ */
52
+ public function process_job( $job, $items_per_batch = null ) {
53
+
54
+ if ( ! isset( $job->total ) ) {
55
+ $job->total = $this->count_remaining_products();
56
+
57
+ if ( empty( $job->total ) ) {
58
+
59
+ // no products or variations need to be excluded from sync, do not display admin notice
60
+ update_option( 'wc_facebook_sync_virtual_products_disabled_skipped', 'yes' );
61
+ }
62
+ }
63
+
64
+ if ( ! isset( $job->progress ) ) {
65
+ $job->progress = 0;
66
+ }
67
+
68
+ $remaining_products = $job->total;
69
+ $processed_products = 0;
70
+
71
+ // disable sync until memory or time limit is exceeded
72
+ while ( $processed_products < $remaining_products ) {
73
+
74
+ $rows_updated = $this->disable_sync();
75
+
76
+ $processed_products += $rows_updated;
77
+ $job->progress += $rows_updated;
78
+
79
+ // update job progress
80
+ $job = $this->update_job( $job );
81
+
82
+ // memory or time limit reached
83
+ if ( $this->time_exceeded() || $this->memory_exceeded() ) {
84
+ break;
85
+ }
86
+ }
87
+
88
+ // job complete! :)
89
+ if ( $this->count_remaining_products() === 0 ) {
90
+
91
+ update_option( 'wc_facebook_sync_virtual_products_disabled', 'yes' );
92
+
93
+ $this->complete_job( $job );
94
+ }
95
+
96
+ return $job;
97
+ }
98
+
99
+
100
+ /**
101
+ * Counts the number of virtual products or product variations with sync enabled.
102
+ *
103
+ * @since 1.11.3-dev.2
104
+ *
105
+ * @return bool
106
+ */
107
+ private function count_remaining_products() {
108
+ global $wpdb;
109
+
110
+ $sql = "
111
+ SELECT COUNT( posts.ID )
112
+ FROM {$wpdb->posts} AS posts
113
+ INNER JOIN {$wpdb->postmeta} AS virtual_meta ON ( posts.ID = virtual_meta.post_id AND virtual_meta.meta_key = '_virtual' AND virtual_meta.meta_value = 'yes' )
114
+ LEFT JOIN {$wpdb->postmeta} AS sync_meta ON ( posts.ID = sync_meta.post_id AND sync_meta.meta_key = '_wc_facebook_sync_enabled' )
115
+ WHERE posts.post_type IN ( 'product', 'product_variation' )
116
+ AND ( sync_meta.meta_value IS NULL OR sync_meta.meta_value = 'yes' )
117
+ ";
118
+
119
+ return (int) $wpdb->get_var( $sql );
120
+ }
121
+
122
+
123
+ /**
124
+ * Update rows into the postmeta table to disable sync.
125
+ *
126
+ * @since 1.11.3-dev.2
127
+ *
128
+ * @return int
129
+ */
130
+ private function disable_sync() {
131
+ global $wpdb;
132
+
133
+ $rows_inserted = 0;
134
+
135
+ // get post IDs to update
136
+ $sql = "
137
+ SELECT DISTINCT( posts.ID )
138
+ FROM {$wpdb->posts} AS posts
139
+ INNER JOIN {$wpdb->postmeta} AS virtual_meta ON ( posts.ID = virtual_meta.post_id AND virtual_meta.meta_key = '_virtual' AND virtual_meta.meta_value = 'yes' )
140
+ LEFT JOIN {$wpdb->postmeta} AS sync_meta ON ( posts.ID = sync_meta.post_id AND sync_meta.meta_key = '_wc_facebook_sync_enabled' )
141
+ WHERE posts.post_type IN ( 'product', 'product_variation' )
142
+ AND ( sync_meta.meta_value IS NULL OR sync_meta.meta_value = 'yes' )
143
+ LIMIT 1000
144
+ ";
145
+
146
+ $post_ids = $wpdb->get_col( $sql );
147
+
148
+ if ( empty( $post_ids ) ) {
149
+
150
+ facebook_for_woocommerce()->log( 'There are no products or products variations to update.' );
151
+
152
+ } else {
153
+
154
+ $post_ids_str = implode( "','", $post_ids );
155
+
156
+ // delete the metadata so we can insert it without creating duplicates
157
+ $sql = "
158
+ DELETE FROM {$wpdb->postmeta}
159
+ WHERE meta_key = '_wc_facebook_sync_enabled'
160
+ AND post_id IN ( '{$post_ids_str}' )
161
+ ";
162
+
163
+ $wpdb->query( $sql );
164
+
165
+ $values = [];
166
+
167
+ foreach ( $post_ids as $post_id ) {
168
+
169
+ $values[] = "('$post_id', '_wc_facebook_sync_enabled', 'no')";
170
+ }
171
+
172
+ $values_str = implode( ',', $values );
173
+
174
+ // we need to explicitly insert the metadata and set it to no, because not having it means sync is enabled
175
+ $sql = "
176
+ INSERT INTO {$wpdb->postmeta} (post_id, meta_key, meta_value )
177
+ VALUES {$values_str}
178
+ ";
179
+
180
+ $rows_inserted = $wpdb->query( $sql );
181
+
182
+ if ( false === $rows_inserted ) {
183
+
184
+ $message = sprintf( 'There was an error trying to set products and variations meta data. %s', $wpdb->last_error );
185
+
186
+ facebook_for_woocommerce()->log( $message );
187
+ }
188
+ }
189
+
190
+ return (int) $rows_inserted;
191
+ }
192
+
193
+
194
+ /**
195
+ * No-op
196
+ *
197
+ * @since 1.11.3-dev.2
198
+ */
199
+ protected function process_item( $item, $job ) {
200
+ // void
201
+ }
202
+
203
+
204
+ }
includes/fbproductfeed.php CHANGED
@@ -288,6 +288,26 @@ if ( ! class_exists( 'WC_Facebook_Product_Feed' ) ) :
288
  }
289
 
290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  /**
292
  * Gets the product catalog feed file directory.
293
  *
@@ -325,6 +345,28 @@ if ( ! class_exists( 'WC_Facebook_Product_Feed' ) ) :
325
  }
326
 
327
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  public function sync_all_products_using_feed() {
329
  $start_time = microtime( true );
330
  $this->log_feed_progress( 'Sync all products using feed' );
@@ -490,15 +532,22 @@ if ( ! class_exists( 'WC_Facebook_Product_Feed' ) ) :
490
 
491
  if ( ! $is_dry_run ) {
492
 
493
- $file_path = $this->get_file_path();
 
494
 
495
- $feed_file = @fopen( $this->get_file_path(), 'w' );
 
 
 
496
 
497
- if ( false === $feed_file || ! is_writable( $file_path ) ) {
 
 
 
498
  throw new Framework\SV_WC_Plugin_Exception( __( 'Could not open the product catalog feed file for writing', 'facebook-for-woocommerce' ), 500 );
499
  }
500
 
501
- fwrite( $feed_file, $this->get_product_feed_header_row() );
502
  }
503
 
504
  $product_group_attribute_variants = array();
@@ -525,13 +574,27 @@ if ( ! class_exists( 'WC_Facebook_Product_Feed' ) ) :
525
  $product_group_attribute_variants
526
  );
527
 
528
- if ( ! empty( $feed_file ) ) {
529
- fwrite( $feed_file, $product_data_as_feed_row );
530
  }
531
  }
532
 
533
  wp_reset_postdata();
534
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535
  $written = true;
536
 
537
  } catch ( Exception $e ) {
@@ -539,10 +602,18 @@ if ( ! class_exists( 'WC_Facebook_Product_Feed' ) ) :
539
  WC_Facebookcommerce_Utils::log( json_encode( $e->getMessage() ) );
540
 
541
  $written = false;
542
- }
543
 
544
- if ( ! empty( $feed_file ) ) {
545
- fclose( $feed_file );
 
 
 
 
 
 
 
 
 
546
  }
547
 
548
  return $written;
288
  }
289
 
290
 
291
+ /**
292
+ * Gets the product catalog temporary feed file path.
293
+ *
294
+ * @since 1.11.3
295
+ *
296
+ * @return string
297
+ */
298
+ public function get_temp_file_path() {
299
+
300
+ /**
301
+ * Filters the product catalog temporary feed file path.
302
+ *
303
+ * @since 1.11.3
304
+ *
305
+ * @param string $file_path the temporary file path
306
+ */
307
+ return apply_filters( 'wc_facebook_product_catalog_temp_feed_file_path', "{$this->get_file_directory()}/{$this->get_temp_file_name()}" );
308
+ }
309
+
310
+
311
  /**
312
  * Gets the product catalog feed file directory.
313
  *
345
  }
346
 
347
 
348
+ /**
349
+ * Gets the product catalog temporary feed file name.
350
+ *
351
+ * @since 1.11.3
352
+ *
353
+ * @return string
354
+ */
355
+ public function get_temp_file_name() {
356
+
357
+ $file_name = sprintf( self::FILE_NAME, 'temp_' . wp_hash( Feed::get_feed_secret() ) );
358
+
359
+ /**
360
+ * Filters the product catalog temporary feed file name.
361
+ *
362
+ * @since 1.11.3
363
+ *
364
+ * @param string $file_name the temporary file name
365
+ */
366
+ return apply_filters( 'wc_facebook_product_catalog_temp_feed_file_name', $file_name );
367
+ }
368
+
369
+
370
  public function sync_all_products_using_feed() {
371
  $start_time = microtime( true );
372
  $this->log_feed_progress( 'Sync all products using feed' );
532
 
533
  if ( ! $is_dry_run ) {
534
 
535
+ $temp_file_path = $this->get_temp_file_path();
536
+ $temp_feed_file = @fopen( $temp_file_path, 'w' );
537
 
538
+ // check if we can open the temporary feed file
539
+ if ( false === $temp_feed_file || ! is_writable( $temp_file_path ) ) {
540
+ throw new Framework\SV_WC_Plugin_Exception( __( 'Could not open the product catalog temporary feed file for writing', 'facebook-for-woocommerce' ), 500 );
541
+ }
542
 
543
+ $file_path = $this->get_file_path();
544
+
545
+ // check if we will be able to write to the final feed file
546
+ if ( file_exists( $file_path ) && ! is_writable( $file_path ) ) {
547
  throw new Framework\SV_WC_Plugin_Exception( __( 'Could not open the product catalog feed file for writing', 'facebook-for-woocommerce' ), 500 );
548
  }
549
 
550
+ fwrite( $temp_feed_file, $this->get_product_feed_header_row() );
551
  }
552
 
553
  $product_group_attribute_variants = array();
574
  $product_group_attribute_variants
575
  );
576
 
577
+ if ( ! empty( $temp_feed_file ) ) {
578
+ fwrite( $temp_feed_file, $product_data_as_feed_row );
579
  }
580
  }
581
 
582
  wp_reset_postdata();
583
 
584
+
585
+ if ( ! empty( $temp_feed_file ) ) {
586
+ fclose( $temp_feed_file );
587
+ }
588
+
589
+ if ( ! empty( $temp_file_path ) && ! empty( $file_path ) && ! empty( $temp_feed_file ) ) {
590
+
591
+ $renamed = rename( $temp_file_path, $file_path );
592
+
593
+ if ( empty( $renamed ) ) {
594
+ throw new Framework\SV_WC_Plugin_Exception( __( 'Could not rename the product catalog feed file', 'facebook-for-woocommerce' ), 500 );
595
+ }
596
+ }
597
+
598
  $written = true;
599
 
600
  } catch ( Exception $e ) {
602
  WC_Facebookcommerce_Utils::log( json_encode( $e->getMessage() ) );
603
 
604
  $written = false;
 
605
 
606
+ // close the temporary file
607
+ if ( ! empty( $temp_feed_file ) && is_resource( $temp_feed_file ) ) {
608
+
609
+ fclose( $temp_feed_file );
610
+ }
611
+
612
+ // delete the temporary file
613
+ if ( ! empty( $temp_file_path ) && file_exists( $temp_file_path ) ) {
614
+
615
+ unlink( $temp_file_path );
616
+ }
617
  }
618
 
619
  return $written;
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.3.2
6
- Stable tag: 1.11.2
7
  Requires PHP: 5.6 or greater
8
  MySQL: 5.6 or greater
9
  License: GPLv2 or later
@@ -39,6 +39,15 @@ When opening a bug on GitHub, please give us as many details as possible.
39
 
40
  == Changelog ==
41
 
 
 
 
 
 
 
 
 
 
42
  = 2020.05.04 - version 1.11.2 =
43
  * Misc - Add support for WooCommerce 4.1
44
 
3
  Tags: facebook, shop, catalog, advertise, pixel, product
4
  Requires at least: 4.4
5
  Tested up to: 5.3.2
6
+ Stable tag: 1.11.3
7
  Requires PHP: 5.6 or greater
8
  MySQL: 5.6 or greater
9
  License: GPLv2 or later
39
 
40
  == Changelog ==
41
 
42
+ = 2020.05.20 - version 1.11.3 =
43
+ * Tweak - Write product feed to a temporary file and rename it when done, to prevent Facebook from downloading an incomplete feed file
44
+ * Tweak - Hide Facebook options for virtual products and virtual variations
45
+ * Tweak - Do not allow merchant to bulk enable sync for virtual products
46
+ * Tweak - On upgrade, automatically disable sync for virtual products and virtual variations
47
+ * Tweak - When using checkboxes for tags, make sure the modal is displayed when trying to enable sync for a product with an excluded tag
48
+ * Fix - Prevent tracking of a duplicated purchase event in some circumstances such as when the customer reloads the "Thank You" page after completing an order
49
+ * Fix - Fix a JavaScript issue that was causing a notice to be displayed when bulk editing product variations
50
+
51
  = 2020.05.04 - version 1.11.2 =
52
  * Misc - Add support for WooCommerce 4.1
53