Facebook for WooCommerce - Version 2.6.15

Version Description

  • 2022-06-01 =
  • Fix - Do not set sale_price when the product is not on sale.
  • Fix - FB Pixel is missing some ajax Add to cart events.
  • Fix - Feed visibility field value for hidden items.
  • Fix - Wrong Value Field in AddToCart Events.
  • Tweak - Not show the removed from sync confirm modal for unpublished products.
Download this release

Release Info

Developer automattic
Plugin Icon Facebook for WooCommerce
Version 2.6.15
Comparing to
See all releases

Code changes from version 2.6.14 to 2.6.15

assets/build/admin/products-admin.asset.php CHANGED
@@ -1 +1 @@
1
- <?php return array('dependencies' => array('wp-polyfill'), 'version' => 'c40e4d58318863c75d4136c0885d16ea');
1
+ <?php return array('dependencies' => array('wp-polyfill'), 'version' => '9a3d46c8f97dbaacd5b0c49075c97e31');
assets/build/admin/products-admin.js CHANGED
@@ -1 +1 @@
1
- !function(o){var e={};function t(c){if(e[c])return e[c].exports;var n=e[c]={i:c,l:!1,exports:{}};return o[c].call(n.exports,n,n.exports,t),n.l=!0,n.exports}t.m=o,t.c=e,t.d=function(o,e,c){t.o(o,e)||Object.defineProperty(o,e,{enumerable:!0,get:c})},t.r=function(o){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},t.t=function(o,e){if(1&e&&(o=t(o)),8&e)return o;if(4&e&&"object"==typeof o&&o&&o.__esModule)return o;var c=Object.create(null);if(t.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:o}),2&e&&"string"!=typeof o)for(var n in o)t.d(c,n,function(e){return o[e]}.bind(null,n));return c},t.n=function(o){var e=o&&o.__esModule?function(){return o.default}:function(){return o};return t.d(e,"a",e),e},t.o=function(o,e){return Object.prototype.hasOwnProperty.call(o,e)},t.p="",t(t.s=10)}({10:function(o,e){jQuery(document).ready((function(o){var e=window.pagenow.length?window.pagenow:"";if(window.typenow.length&&window.typenow,"edit-product"===e){var t=!1;o("input#doaction, input#doaction2").on("click",(function(e){if(t)return!0;e.preventDefault();var c=o(this),n=c.prev("select").val();if("facebook_include"===n){var r=[];o.each(o('input[name="post[]"]:checked'),(function(){r.push(parseInt(o(this).val(),10))})),o.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:n,products:r},(function(e){e&&!e.success?(closeExistingModal(),new o.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:e.data})):(t=!0,c.trigger("click"))}))}else t=!0,c.trigger("click")}))}if("product"===e){function c(o,e){e.find(".enable-if-sync-enabled").prop("disabled",!o)}function n(o,e){o?(e.find("option[value='sync_and_show']").show(),e.prop("original")&&e.val(e.prop("original"))):(e.find("option[value='sync_and_show']").hide(),"sync_and_show"===e.val()&&e.val("sync_and_hide"))}function r(o,e){var t=e.find("#wc_facebook_commerce_enabled"),c=t.prop("original");t.prop("checked",!!o&&c).prop("disabled",!o),t.trigger("change"),t.prop("original",c),e.find("#product-not-ready-notice, #variable-product-not-ready-notice").hide(),s()&&!i()?e.find("#variable-product-not-ready-notice").show():o||e.find("#product-not-ready-notice").show()}function a(){return!!(s()?i():"sync_disabled"!==v.val())&&!!(s()||(o("#_regular_price").val()||o("#fb_product_price").val()))&&!(!o("#_manage_stock").prop("checked")||!o("#_stock").val())}function i(){var e=o(".js-variable-fb-sync-toggle");return 0===e.length?!!facebook_for_woocommerce_products_admin.is_sync_enabled_for_product:!!e.map((function(e,t){return"sync_disabled"!==o(t).val()?t:null})).length}function s(){var e=o("select#product-type").val();return!(!e||!e.match(/variable/))}function d(o){o.attr("data-original-value",o.val())}function l(e){return e.map((function(e,t){var c=o(t),n=c.val();return"sync_disabled"===n&&n!==c.attr("data-original-value")})).toArray().indexOf(!0)>-1}function _(e){return v===e?o("input#post_ID").val():e.closest(".woocommerce_variation").find("input[name^=variable_post_id]").val()}function u(e){closeExistingModal(),m=e,g=_(e),new o.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:{message:facebook_for_woocommerce_products_admin.product_removed_from_sync_confirm_modal_message,buttons:facebook_for_woocommerce_products_admin.product_removed_from_sync_confirm_modal_buttons}})}function f(){o(facebook_for_woocommerce_products_admin.product_removed_from_sync_field_id).val(b.join(","))}function p(o){b=b.filter((function(e){return e!==o})),f()}var m=null,g=null,b=[];o(document.body).on("click","button.button-product-removed-from-sync-delete",(function(){g&&(closeExistingModal(),b.push(g),f())})).on("click","button.button-product-removed-from-sync-cancel",(function(){var o;closeExistingModal(),m&&((o=m).val(o.attr("data-original-value")),m=null),f()})),o("#facebook_options #wc_facebook_commerce_enabled").on("change",(function(){var e=o(this).prop("checked");e?o(".wc_facebook_commerce_fields").show():o(".wc_facebook_commerce_fields").hide(),o(".product_attributes").find(".woocommerce_attribute").length?o(".show_if_has_attributes").show():o(".show_if_has_attributes").hide(),o(this).prop("original",e)})).trigger("change");var v=o("#wc_facebook_sync_mode"),h=v.closest(".woocommerce_options_panel");d(v),v.on("change",(function(){var o,e,t="sync_disabled"!==v.val();c(t,h),o=t,e=h.find(".wc-facebook-commerce-options-group"),o?e.show():e.hide(),t&&p(_(v)),v.prop("original",v.val()),l(v)&&u(v)})).trigger("change"),o("#_virtual").on("change",(function(){n(!o(this).prop("checked"),v)})).trigger("change");var w=o("#woocommerce-product-data");w.on("change","#_regular_price, #_manage_stock, #_stock, #wc_facebook_sync_mode, #fb_product_price",(function(e){setTimeout((function(){r(a(),o("#facebook_options"))}),1)})),o(".woocommerce_variations").on("change",".js-variable-fb-sync-toggle",(function(){var e=o(this),t="sync_disabled"!==e.val();c(t,e.closest(".wc-metabox-content")),r(a(),o("#facebook_options")),t&&p(_(e)),e.prop("original",e.val()),l(e)&&u(e)})),w.on("woocommerce_variations_loaded",(function(){w.find(".js-variable-fb-sync-toggle").each((function(e,t){var n=o(t);c("sync_disabled"!==n.val(),n.closest(".wc-metabox-content")),n.prop("original",n.val()),d(n)})),o(".variable_is_virtual").on("change",(function(){var e=o(this).closest(".wc-metabox-content").find(".js-variable-fb-sync-toggle");n(!o(this).prop("checked"),e)})),r(a(),o("#facebook_options"))})),w.on("change",".js-fb-product-image-source",(function(){var e=o(this).closest(".woocommerce_options_panel, .wc-metabox-content"),t=o(this).val();e.find(".product-image-source-field").closest(".form-field").hide(),e.find(".show-if-product-image-source-".concat(t)).closest(".form-field").show()})),o(".js-fb-product-image-source:checked:visible").trigger("change"),w.on("woocommerce_variations_loaded",(function(){o(".js-variable-fb-sync-toggle:visible").trigger("change"),o(".js-fb-product-image-source:checked:visible").trigger("change"),o(".variable_is_virtual:visible").trigger("change")})),o("#facebook_options").on("click","#product-not-ready-notice-open-modal",(function(e){e.preventDefault(),closeExistingModal(),new o.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:{message:facebook_for_woocommerce_products_admin.product_not_ready_modal_message,buttons:facebook_for_woocommerce_products_admin.product_not_ready_modal_buttons}})})),r(a(),h);var y=!1;o('form#post input[type="submit"]').on("click",(function(e){if(o("#wc_facebook_commerce_enabled").prop("checked")&&a()&&o(".wc_facebook_commerce_fields .wc-facebook-google-product-category-select").map((function(e,t){return o(t).val()?o(t).val():null})).length<2)return e.preventDefault(),alert(facebook_for_woocommerce_products_admin.i18n.missing_google_product_category_message),!1;if(y)return!0;e.preventDefault();var t=o(this),c=parseInt(o("input#post_ID").val(),10),n=[],r=o('textarea[name="tax_input[product_tag]"]').length?o('textarea[name="tax_input[product_tag]"]').val().split(","):[],s="sync_disabled"!==v.val(),d=i();o('#taxonomy-product_cat input[name="tax_input[product_cat][]"]:checked').each((function(){n.push(parseInt(o(this).val(),10))})),o('#taxonomy-product_tag input[name="tax_input[product_tag][]"]:checked').each((function(){r.push(parseInt(o(this).val(),10))})),c>0?o.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:s?"enabled":"disabled",var_sync_enabled:d?"enabled":"disabled",product:c,categories:n,tags:r},(function(e){e&&!e.success&&s?(closeExistingModal(),new o.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:e.data})):(y=!0,t.trigger("click"))})):(y=!0,t.trigger("click"))}))}}))}});
1
+ !function(o){var e={};function t(c){if(e[c])return e[c].exports;var n=e[c]={i:c,l:!1,exports:{}};return o[c].call(n.exports,n,n.exports,t),n.l=!0,n.exports}t.m=o,t.c=e,t.d=function(o,e,c){t.o(o,e)||Object.defineProperty(o,e,{enumerable:!0,get:c})},t.r=function(o){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},t.t=function(o,e){if(1&e&&(o=t(o)),8&e)return o;if(4&e&&"object"==typeof o&&o&&o.__esModule)return o;var c=Object.create(null);if(t.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:o}),2&e&&"string"!=typeof o)for(var n in o)t.d(c,n,function(e){return o[e]}.bind(null,n));return c},t.n=function(o){var e=o&&o.__esModule?function(){return o.default}:function(){return o};return t.d(e,"a",e),e},t.o=function(o,e){return Object.prototype.hasOwnProperty.call(o,e)},t.p="",t(t.s=10)}({10:function(o,e){jQuery(document).ready((function(o){var e=window.pagenow.length?window.pagenow:"";if(window.typenow.length&&window.typenow,"edit-product"===e){var t=!1;o("input#doaction, input#doaction2").on("click",(function(e){if(t)return!0;e.preventDefault();var c=o(this),n=c.prev("select").val();if("facebook_include"===n){var r=[];o.each(o('input[name="post[]"]:checked'),(function(){r.push(parseInt(o(this).val(),10))})),o.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:n,products:r},(function(e){e&&!e.success?(closeExistingModal(),new o.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:e.data})):(t=!0,c.trigger("click"))}))}else t=!0,c.trigger("click")}))}if("product"===e){function c(o,e){e.find(".enable-if-sync-enabled").prop("disabled",!o)}function n(o,e){o?(e.find("option[value='sync_and_show']").show(),e.prop("original")&&e.val(e.prop("original"))):(e.find("option[value='sync_and_show']").hide(),"sync_and_show"===e.val()&&e.val("sync_and_hide"))}function r(o,e){var t=e.find("#wc_facebook_commerce_enabled"),c=t.prop("original");t.prop("checked",!!o&&c).prop("disabled",!o),t.trigger("change"),t.prop("original",c),e.find("#product-not-ready-notice, #variable-product-not-ready-notice").hide(),s()&&!i()?e.find("#variable-product-not-ready-notice").show():o||e.find("#product-not-ready-notice").show()}function a(){return!!(s()?i():"sync_disabled"!==v.val())&&!!(s()||(o("#_regular_price").val()||o("#fb_product_price").val()))&&!(!o("#_manage_stock").prop("checked")||!o("#_stock").val())}function i(){var e=o(".js-variable-fb-sync-toggle");return 0===e.length?!!facebook_for_woocommerce_products_admin.is_sync_enabled_for_product:!!e.map((function(e,t){return"sync_disabled"!==o(t).val()?t:null})).length}function s(){var e=o("select#product-type").val();return!(!e||!e.match(/variable/))}function d(o){o.attr("data-original-value",o.val())}function _(e){return e.map((function(e,t){var c=o(t),n=c.val();return!!facebook_for_woocommerce_products_admin.is_product_published&&"sync_disabled"===n&&n!==c.attr("data-original-value")})).toArray().indexOf(!0)>-1}function l(e){return v===e?o("input#post_ID").val():e.closest(".woocommerce_variation").find("input[name^=variable_post_id]").val()}function u(e){closeExistingModal(),m=e,g=l(e),new o.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:{message:facebook_for_woocommerce_products_admin.product_removed_from_sync_confirm_modal_message,buttons:facebook_for_woocommerce_products_admin.product_removed_from_sync_confirm_modal_buttons}})}function f(){o(facebook_for_woocommerce_products_admin.product_removed_from_sync_field_id).val(b.join(","))}function p(o){b=b.filter((function(e){return e!==o})),f()}var m=null,g=null,b=[];o(document.body).on("click","button.button-product-removed-from-sync-delete",(function(){g&&(closeExistingModal(),b.push(g),f())})).on("click","button.button-product-removed-from-sync-cancel",(function(){var o;closeExistingModal(),m&&((o=m).val(o.attr("data-original-value")),m=null),f()})),o("#facebook_options #wc_facebook_commerce_enabled").on("change",(function(){var e=o(this).prop("checked");e?o(".wc_facebook_commerce_fields").show():o(".wc_facebook_commerce_fields").hide(),o(".product_attributes").find(".woocommerce_attribute").length?o(".show_if_has_attributes").show():o(".show_if_has_attributes").hide(),o(this).prop("original",e)})).trigger("change");var v=o("#wc_facebook_sync_mode"),h=v.closest(".woocommerce_options_panel");d(v),v.on("change",(function(){var o,e,t="sync_disabled"!==v.val();c(t,h),o=t,e=h.find(".wc-facebook-commerce-options-group"),o?e.show():e.hide(),t&&p(l(v)),v.prop("original",v.val()),_(v)&&u(v)})).trigger("change"),o("#_virtual").on("change",(function(){n(!o(this).prop("checked"),v)})).trigger("change");var w=o("#woocommerce-product-data");w.on("change","#_regular_price, #_manage_stock, #_stock, #wc_facebook_sync_mode, #fb_product_price",(function(e){setTimeout((function(){r(a(),o("#facebook_options"))}),1)})),o(".woocommerce_variations").on("change",".js-variable-fb-sync-toggle",(function(){var e=o(this),t="sync_disabled"!==e.val();c(t,e.closest(".wc-metabox-content")),r(a(),o("#facebook_options")),t&&p(l(e)),e.prop("original",e.val()),_(e)&&u(e)})),w.on("woocommerce_variations_loaded",(function(){w.find(".js-variable-fb-sync-toggle").each((function(e,t){var n=o(t);c("sync_disabled"!==n.val(),n.closest(".wc-metabox-content")),n.prop("original",n.val()),d(n)})),o(".variable_is_virtual").on("change",(function(){var e=o(this).closest(".wc-metabox-content").find(".js-variable-fb-sync-toggle");n(!o(this).prop("checked"),e)})),r(a(),o("#facebook_options"))})),w.on("change",".js-fb-product-image-source",(function(){var e=o(this).closest(".woocommerce_options_panel, .wc-metabox-content"),t=o(this).val();e.find(".product-image-source-field").closest(".form-field").hide(),e.find(".show-if-product-image-source-".concat(t)).closest(".form-field").show()})),o(".js-fb-product-image-source:checked:visible").trigger("change"),w.on("woocommerce_variations_loaded",(function(){o(".js-variable-fb-sync-toggle:visible").trigger("change"),o(".js-fb-product-image-source:checked:visible").trigger("change"),o(".variable_is_virtual:visible").trigger("change")})),o("#facebook_options").on("click","#product-not-ready-notice-open-modal",(function(e){e.preventDefault(),closeExistingModal(),new o.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:{message:facebook_for_woocommerce_products_admin.product_not_ready_modal_message,buttons:facebook_for_woocommerce_products_admin.product_not_ready_modal_buttons}})})),r(a(),h);var k=!1;o('form#post input[type="submit"]').on("click",(function(e){if(o("#wc_facebook_commerce_enabled").prop("checked")&&a()&&o(".wc_facebook_commerce_fields .wc-facebook-google-product-category-select").map((function(e,t){return o(t).val()?o(t).val():null})).length<2)return e.preventDefault(),alert(facebook_for_woocommerce_products_admin.i18n.missing_google_product_category_message),!1;if(k)return!0;e.preventDefault();var t=o(this),c=parseInt(o("input#post_ID").val(),10),n=[],r=o('textarea[name="tax_input[product_tag]"]').length?o('textarea[name="tax_input[product_tag]"]').val().split(","):[],s="sync_disabled"!==v.val(),d=i();o('#taxonomy-product_cat input[name="tax_input[product_cat][]"]:checked').each((function(){n.push(parseInt(o(this).val(),10))})),o('#taxonomy-product_tag input[name="tax_input[product_tag][]"]:checked').each((function(){r.push(parseInt(o(this).val(),10))})),c>0?o.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:s?"enabled":"disabled",var_sync_enabled:d?"enabled":"disabled",product:c,categories:n,tags:r},(function(e){e&&!e.success&&s?(closeExistingModal(),new o.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:e.data})):(k=!0,t.trigger("click"))})):(k=!0,t.trigger("click"))}))}}))}});
assets/js/admin/products-admin.js CHANGED
@@ -407,10 +407,11 @@ jQuery( document ).ready( function( $ ) {
407
 
408
  let syncValuesStatus = $syncModeSelect.map( function ( index, selectElement ) {
409
 
410
- let $syncMode = $( selectElement );
411
- let syncModeValue = $syncMode.val();
 
412
 
413
- return 'sync_disabled' === syncModeValue && syncModeValue !== $syncMode.attr( 'data-original-value' );
414
  } ).toArray();
415
 
416
  return syncValuesStatus.indexOf( true ) > -1;
407
 
408
  let syncValuesStatus = $syncModeSelect.map( function ( index, selectElement ) {
409
 
410
+ let $syncMode = $( selectElement );
411
+ let syncModeValue = $syncMode.val();
412
+ let isProductPublished = !! facebook_for_woocommerce_products_admin.is_product_published;
413
 
414
+ return isProductPublished && 'sync_disabled' === syncModeValue && syncModeValue !== $syncMode.attr( 'data-original-value' );
415
  } ).toArray();
416
 
417
  return syncValuesStatus.indexOf( true ) > -1;
changelog.txt CHANGED
@@ -1,6 +1,13 @@
1
  *** Facebook for WooCommerce Changelog ***
2
 
3
- 2022-05-18 - version 2.6.14
 
 
 
 
 
 
 
4
  * Fix - Non-latin custom product attribute names sync.
5
  * Fix - Syncing brand FB attribute instead of the website name.
6
  * Fix - Trigger InitiateCheckout event when site uses checkout block.
1
  *** Facebook for WooCommerce Changelog ***
2
 
3
+ 2022-06-01 - version 2.6.15
4
+ * Fix - Do not set `sale_price` when the product is not on sale.
5
+ * Fix - FB Pixel is missing some ajax Add to cart events.
6
+ * Fix - Feed visibility field value for hidden items.
7
+ * Fix - Wrong Value Field in AddToCart Events.
8
+ * Tweak - Not show the removed from sync confirm modal for unpublished products.
9
+
10
+ 2022-05-18 - version 2.6.14
11
  * Fix - Non-latin custom product attribute names sync.
12
  * Fix - Syncing brand FB attribute instead of the website name.
13
  * Fix - Trigger InitiateCheckout event when site uses checkout block.
facebook-commerce-events-tracker.php CHANGED
@@ -118,7 +118,7 @@ if ( ! class_exists( 'WC_Facebookcommerce_EventsTracker' ) ) :
118
  // AddToCart while AJAX is enabled
119
  add_action( 'woocommerce_ajax_added_to_cart', array( $this, 'add_filter_for_add_to_cart_fragments' ) );
120
  // AddToCart while using redirect to cart page
121
- if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
122
  add_filter( 'woocommerce_add_to_cart_redirect', array( $this, 'set_last_product_added_to_cart_upon_redirect' ), 10, 2 );
123
  add_action( 'woocommerce_ajax_added_to_cart', array( $this, 'set_last_product_added_to_cart_upon_ajax_redirect' ) );
124
  add_action( 'woocommerce_after_cart', array( $this, 'inject_add_to_cart_redirect_event' ), 10, 2 );
@@ -587,11 +587,18 @@ if ( ! class_exists( 'WC_Facebookcommerce_EventsTracker' ) ) :
587
  $event_data = array(
588
  'event_name' => 'AddToCart',
589
  'custom_data' => array(
590
- 'content_ids' => $this->get_cart_content_ids(),
591
- 'content_name' => $this->get_cart_content_names(),
592
  'content_type' => 'product',
593
- 'contents' => $this->get_cart_contents(),
594
- 'value' => $this->get_cart_total(),
 
 
 
 
 
 
 
595
  'currency' => get_woocommerce_currency(),
596
  ),
597
  'user_data' => $this->pixel->get_user_info(),
@@ -622,7 +629,7 @@ if ( ! class_exists( 'WC_Facebookcommerce_EventsTracker' ) ) :
622
  */
623
  public function add_filter_for_add_to_cart_fragments() {
624
 
625
- if ( 'no' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
626
  add_filter( 'woocommerce_add_to_cart_fragments', array( $this, 'add_add_to_cart_event_fragment' ) );
627
  }
628
  }
@@ -640,20 +647,35 @@ if ( ! class_exists( 'WC_Facebookcommerce_EventsTracker' ) ) :
640
  */
641
  public function add_add_to_cart_event_fragment( $fragments ) {
642
 
 
 
 
 
 
 
 
 
 
643
  if ( $this->is_pixel_enabled() ) {
644
 
645
  $params = array(
646
- 'content_ids' => $this->get_cart_content_ids(),
647
- 'content_name' => $this->get_cart_content_names(),
648
  'content_type' => 'product',
649
- 'contents' => $this->get_cart_contents(),
650
- 'value' => $this->get_cart_total(),
 
 
 
 
 
 
 
651
  'currency' => get_woocommerce_currency(),
652
  );
653
 
654
  // send the event ID to prevent duplication
655
  if ( ! empty( $event_id = WC()->session->get( 'facebook_for_woocommerce_add_to_cart_event_id' ) ) ) {
656
-
657
  $params['event_id'] = $event_id;
658
  }
659
 
@@ -679,7 +701,7 @@ if ( ! class_exists( 'WC_Facebookcommerce_EventsTracker' ) ) :
679
  */
680
  public function add_filter_for_conditional_add_to_cart_fragment() {
681
 
682
- if ( 'no' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
683
  add_filter( 'woocommerce_add_to_cart_fragments', array( $this, 'add_conditional_add_to_cart_event_fragment' ) );
684
  }
685
  }
118
  // AddToCart while AJAX is enabled
119
  add_action( 'woocommerce_ajax_added_to_cart', array( $this, 'add_filter_for_add_to_cart_fragments' ) );
120
  // AddToCart while using redirect to cart page
121
+ if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add', 'no' ) ) {
122
  add_filter( 'woocommerce_add_to_cart_redirect', array( $this, 'set_last_product_added_to_cart_upon_redirect' ), 10, 2 );
123
  add_action( 'woocommerce_ajax_added_to_cart', array( $this, 'set_last_product_added_to_cart_upon_ajax_redirect' ) );
124
  add_action( 'woocommerce_after_cart', array( $this, 'inject_add_to_cart_redirect_event' ), 10, 2 );
587
  $event_data = array(
588
  'event_name' => 'AddToCart',
589
  'custom_data' => array(
590
+ 'content_ids' => wp_json_encode( \WC_Facebookcommerce_Utils::get_fb_content_ids( $product ) ),
591
+ 'content_name' => $product->get_name(),
592
  'content_type' => 'product',
593
+ 'contents' => wp_json_encode(
594
+ array(
595
+ array(
596
+ "id" => \WC_Facebookcommerce_Utils::get_fb_retailer_id( $product ),
597
+ "quantity" => $quantity,
598
+ ),
599
+ )
600
+ ),
601
+ 'value' => (float) $product->get_price() * $quantity,
602
  'currency' => get_woocommerce_currency(),
603
  ),
604
  'user_data' => $this->pixel->get_user_info(),
629
  */
630
  public function add_filter_for_add_to_cart_fragments() {
631
 
632
+ if ( 'no' === get_option( 'woocommerce_cart_redirect_after_add', 'no' ) ) {
633
  add_filter( 'woocommerce_add_to_cart_fragments', array( $this, 'add_add_to_cart_event_fragment' ) );
634
  }
635
  }
647
  */
648
  public function add_add_to_cart_event_fragment( $fragments ) {
649
 
650
+ $product_id = isset( $_POST['product_id'] ) ? (int) $_POST['product_id'] : '';
651
+ $quantity = isset( $_POST['quantity']) ? (int) $_POST['quantity'] : '';
652
+ $product = wc_get_product($product_id);
653
+
654
+ if ( ! $product instanceof \WC_Product || empty( $quantity ) ) {
655
+ return $fragments;
656
+ }
657
+
658
+
659
  if ( $this->is_pixel_enabled() ) {
660
 
661
  $params = array(
662
+ 'content_ids' => wp_json_encode( \WC_Facebookcommerce_Utils::get_fb_content_ids( $product ) ),
663
+ 'content_name' => $product->get_name(),
664
  'content_type' => 'product',
665
+ 'contents' => wp_json_encode(
666
+ array(
667
+ array(
668
+ 'id' => \WC_Facebookcommerce_Utils::get_fb_retailer_id( $product ),
669
+ 'quantity' => $quantity,
670
+ ),
671
+ )
672
+ ),
673
+ 'value' => (float) $product->get_price() * $quantity,
674
  'currency' => get_woocommerce_currency(),
675
  );
676
 
677
  // send the event ID to prevent duplication
678
  if ( ! empty( $event_id = WC()->session->get( 'facebook_for_woocommerce_add_to_cart_event_id' ) ) ) {
 
679
  $params['event_id'] = $event_id;
680
  }
681
 
701
  */
702
  public function add_filter_for_conditional_add_to_cart_fragment() {
703
 
704
+ if ( 'no' === get_option( 'woocommerce_cart_redirect_after_add', 'no' ) ) {
705
  add_filter( 'woocommerce_add_to_cart_fragments', array( $this, 'add_conditional_add_to_cart_event_fragment' ) );
706
  }
707
  }
facebook-commerce.php CHANGED
@@ -155,7 +155,7 @@ class WC_Facebookcommerce_Integration extends WC_Integration {
155
  const FB_SHOP_PRODUCT_VISIBLE = 'published';
156
 
157
  /** @var string the API flag to set a product as not visible in the Facebook shop */
158
- const FB_SHOP_PRODUCT_HIDDEN = 'staging';
159
 
160
  /** @var string @deprecated */
161
  const FB_CART_URL = 'fb_cart_url';
155
  const FB_SHOP_PRODUCT_VISIBLE = 'published';
156
 
157
  /** @var string the API flag to set a product as not visible in the Facebook shop */
158
+ const FB_SHOP_PRODUCT_HIDDEN = 'hidden';
159
 
160
  /** @var string @deprecated */
161
  const FB_CART_URL = 'fb_cart_url';
facebook-for-woocommerce.php CHANGED
@@ -11,7 +11,7 @@
11
  * 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.
12
  * Author: Facebook
13
  * Author URI: https://www.facebook.com/
14
- * Version: 2.6.14
15
  * Text Domain: facebook-for-woocommerce
16
  * Tested up to: 6.0
17
  * WC requires at least: 3.5.0
@@ -33,7 +33,7 @@ class WC_Facebook_Loader {
33
  /**
34
  * @var string the plugin version. This must be in the main plugin file to be automatically bumped by Woorelease.
35
  */
36
- const PLUGIN_VERSION = '2.6.14'; // WRCS: DEFINED_VERSION.
37
 
38
  // Minimum PHP version required by this plugin.
39
  const MINIMUM_PHP_VERSION = '7.0.0';
11
  * 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.
12
  * Author: Facebook
13
  * Author URI: https://www.facebook.com/
14
+ * Version: 2.6.15
15
  * Text Domain: facebook-for-woocommerce
16
  * Tested up to: 6.0
17
  * WC requires at least: 3.5.0
33
  /**
34
  * @var string the plugin version. This must be in the main plugin file to be automatically bumped by Woorelease.
35
  */
36
+ const PLUGIN_VERSION = '2.6.15'; // WRCS: DEFINED_VERSION.
37
 
38
  // Minimum PHP version required by this plugin.
39
  const MINIMUM_PHP_VERSION = '7.0.0';
i18n/languages/facebook-for-woocommerce.pot CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the same license as the Facebook for WooCommerce package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Facebook for WooCommerce 2.6.14\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
- "POT-Creation-Date: 2022-05-18 10:03:34+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -226,7 +226,7 @@ msgstr ""
226
 
227
  #: includes/AJAX.php:348 includes/AJAX.php:416 includes/AJAX.php:482
228
  #: includes/Admin/Product_Categories.php:119
229
- #: includes/Admin/Settings_Screens/Product_Sync.php:158 includes/Admin.php:392
230
  msgid "Cancel"
231
  msgstr ""
232
 
@@ -692,41 +692,41 @@ msgstr ""
692
  msgid "The name is how it appears on Facebook Catalog."
693
  msgstr ""
694
 
695
- #: includes/Admin.php:213
696
  msgid ""
697
  "Please enter a Google product category and at least one sub-category to "
698
  "sell this product on Instagram."
699
  msgstr ""
700
 
701
- #: includes/Admin.php:239
702
  msgid "Search main categories..."
703
  msgstr ""
704
 
705
- #: includes/Admin.php:240
706
  msgid "Choose a main category"
707
  msgstr ""
708
 
709
- #: includes/Admin.php:241
710
  msgid "Choose a category"
711
  msgstr ""
712
 
713
- #: includes/Admin.php:280
714
  msgid ""
715
  "To sell this product on Instagram, please ensure it meets the following "
716
  "requirements:"
717
  msgstr ""
718
 
719
- #: includes/Admin.php:283
720
  msgid "Has a price defined"
721
  msgstr ""
722
 
723
- #: includes/Admin.php:289
724
  #. translators: Placeholders: %1$s - <strong> opening HTML tag, %2$s -
725
  #. </strong> closing HTML tag
726
  msgid "Has %1$sManage Stock%2$s enabled on the %1$sInventory%2$s tab"
727
  msgstr ""
728
 
729
- #: includes/Admin.php:301
730
  #. translators: Placeholders: %1$s - <strong> opening HTML tag, %2$s -
731
  #. </strong> closing HTML tag
732
  msgid ""
@@ -734,11 +734,11 @@ msgid ""
734
  "and hide\""
735
  msgstr ""
736
 
737
- #: includes/Admin.php:330
738
  msgid "Close"
739
  msgstr ""
740
 
741
- #: includes/Admin.php:355
742
  #. translators: Placeholders: %1$s - opening <a> link tag, %2$s - closing </a>
743
  #. link tag
744
  msgid ""
@@ -747,44 +747,44 @@ msgid ""
747
  "the Facebook catalog as well?"
748
  msgstr ""
749
 
750
- #: includes/Admin.php:384
751
  msgid "Remove from sync only"
752
  msgstr ""
753
 
754
- #: includes/Admin.php:388
755
  msgid "Remove from sync and delete"
756
  msgstr ""
757
 
758
- #: includes/Admin.php:424 includes/Admin.php:1267 includes/Admin.php:1409
759
  msgid "Facebook sync"
760
  msgstr ""
761
 
762
- #: includes/Admin.php:451 includes/Admin.php:482
763
  msgid "Sync and show"
764
  msgstr ""
765
 
766
- #: includes/Admin.php:453 includes/Admin.php:483
767
  msgid "Sync and hide"
768
  msgstr ""
769
 
770
- #: includes/Admin.php:457 includes/Admin.php:484 includes/Admin.php:1271
771
- #: includes/Admin.php:1413
772
  msgid "Do not sync"
773
  msgstr ""
774
 
775
- #: includes/Admin.php:481
776
  msgid "Filter by Facebook sync setting"
777
  msgstr ""
778
 
779
- #: includes/Admin.php:894
780
  msgid "Include in Facebook sync"
781
  msgstr ""
782
 
783
- #: includes/Admin.php:895
784
  msgid "Exclude from Facebook sync"
785
  msgstr ""
786
 
787
- #: includes/Admin.php:1088
788
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
789
  #. <a> tag, %4$s - <a> tag
790
  msgid ""
@@ -798,11 +798,11 @@ msgid_plural ""
798
  msgstr[0] ""
799
  msgstr[1] ""
800
 
801
- #: includes/Admin.php:1095
802
  msgid "Don't show this notice again"
803
  msgstr ""
804
 
805
- #: includes/Admin.php:1129
806
  #. translators: Placeholders: %1$s - number of affected products, %2$s opening
807
  #. HTML <a> tag, %3$s - closing HTML </a> tag, %4$s - opening HTML <a> tag,
808
  #. %5$s - closing HTML </a> tag
@@ -819,7 +819,7 @@ msgid_plural ""
819
  msgstr[0] ""
820
  msgstr[1] ""
821
 
822
- #: includes/Admin.php:1195
823
  #. translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing
824
  #. HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a>
825
  #. tag
@@ -829,69 +829,69 @@ msgid ""
829
  "your Facebook catalog. You may still advertise Virtual products on Facebook."
830
  msgstr ""
831
 
832
- #: includes/Admin.php:1269 includes/Admin.php:1411
833
  msgid "Sync and show in catalog"
834
  msgstr ""
835
 
836
- #: includes/Admin.php:1270 includes/Admin.php:1412
837
  msgid "Sync and hide in catalog"
838
  msgstr ""
839
 
840
- #: includes/Admin.php:1280 includes/Admin.php:1425
841
  msgid "Facebook Description"
842
  msgstr ""
843
 
844
- #: includes/Admin.php:1282 includes/Admin.php:1427
845
  msgid ""
846
  "Custom (plain-text only) description for product on Facebook. If blank, "
847
  "product description will be used. If product description is blank, "
848
  "shortname will be used."
849
  msgstr ""
850
 
851
- #: includes/Admin.php:1293 includes/Admin.php:1440
852
  msgid "Facebook Product Image"
853
  msgstr ""
854
 
855
- #: includes/Admin.php:1295 includes/Admin.php:1442
856
  msgid ""
857
  "Choose the product image that should be synced to the Facebook catalog for "
858
  "this product. If using a custom image, please enter an absolute URL (e.g. "
859
  "https://domain.com/image.jpg)."
860
  msgstr ""
861
 
862
- #: includes/Admin.php:1297
863
  msgid "Use WooCommerce image"
864
  msgstr ""
865
 
866
- #: includes/Admin.php:1298 includes/Admin.php:1446
867
  msgid "Use custom image"
868
  msgstr ""
869
 
870
- #: includes/Admin.php:1309 includes/Admin.php:1458
871
  msgid "Custom Image URL"
872
  msgstr ""
873
 
874
- #: includes/Admin.php:1320 includes/Admin.php:1471
875
  #. translators: Placeholders %1$s - WC currency symbol
876
  msgid "Facebook Price (%1$s)"
877
  msgstr ""
878
 
879
- #: includes/Admin.php:1324 includes/Admin.php:1475
880
  msgid ""
881
  "Custom price for product on Facebook. Please enter in monetary decimal (.) "
882
  "format without thousand separators and currency symbols. If blank, product "
883
  "price will be used."
884
  msgstr ""
885
 
886
- #: includes/Admin.php:1444
887
  msgid "Use variation image"
888
  msgstr ""
889
 
890
- #: includes/Admin.php:1445
891
  msgid "Use parent image"
892
  msgstr ""
893
 
894
- #: includes/Admin.php:1599
895
  msgid "Close modal panel"
896
  msgstr ""
897
 
2
  # This file is distributed under the same license as the Facebook for WooCommerce package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Facebook for WooCommerce 2.6.15\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
+ "POT-Creation-Date: 2022-06-01 11:53:06+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
226
 
227
  #: includes/AJAX.php:348 includes/AJAX.php:416 includes/AJAX.php:482
228
  #: includes/Admin/Product_Categories.php:119
229
+ #: includes/Admin/Settings_Screens/Product_Sync.php:158 includes/Admin.php:411
230
  msgid "Cancel"
231
  msgstr ""
232
 
692
  msgid "The name is how it appears on Facebook Catalog."
693
  msgstr ""
694
 
695
+ #: includes/Admin.php:214
696
  msgid ""
697
  "Please enter a Google product category and at least one sub-category to "
698
  "sell this product on Instagram."
699
  msgstr ""
700
 
701
+ #: includes/Admin.php:240
702
  msgid "Search main categories..."
703
  msgstr ""
704
 
705
+ #: includes/Admin.php:241
706
  msgid "Choose a main category"
707
  msgstr ""
708
 
709
+ #: includes/Admin.php:242
710
  msgid "Choose a category"
711
  msgstr ""
712
 
713
+ #: includes/Admin.php:299
714
  msgid ""
715
  "To sell this product on Instagram, please ensure it meets the following "
716
  "requirements:"
717
  msgstr ""
718
 
719
+ #: includes/Admin.php:302
720
  msgid "Has a price defined"
721
  msgstr ""
722
 
723
+ #: includes/Admin.php:308
724
  #. translators: Placeholders: %1$s - <strong> opening HTML tag, %2$s -
725
  #. </strong> closing HTML tag
726
  msgid "Has %1$sManage Stock%2$s enabled on the %1$sInventory%2$s tab"
727
  msgstr ""
728
 
729
+ #: includes/Admin.php:320
730
  #. translators: Placeholders: %1$s - <strong> opening HTML tag, %2$s -
731
  #. </strong> closing HTML tag
732
  msgid ""
734
  "and hide\""
735
  msgstr ""
736
 
737
+ #: includes/Admin.php:349
738
  msgid "Close"
739
  msgstr ""
740
 
741
+ #: includes/Admin.php:374
742
  #. translators: Placeholders: %1$s - opening <a> link tag, %2$s - closing </a>
743
  #. link tag
744
  msgid ""
747
  "the Facebook catalog as well?"
748
  msgstr ""
749
 
750
+ #: includes/Admin.php:403
751
  msgid "Remove from sync only"
752
  msgstr ""
753
 
754
+ #: includes/Admin.php:407
755
  msgid "Remove from sync and delete"
756
  msgstr ""
757
 
758
+ #: includes/Admin.php:443 includes/Admin.php:1286 includes/Admin.php:1428
759
  msgid "Facebook sync"
760
  msgstr ""
761
 
762
+ #: includes/Admin.php:470 includes/Admin.php:501
763
  msgid "Sync and show"
764
  msgstr ""
765
 
766
+ #: includes/Admin.php:472 includes/Admin.php:502
767
  msgid "Sync and hide"
768
  msgstr ""
769
 
770
+ #: includes/Admin.php:476 includes/Admin.php:503 includes/Admin.php:1290
771
+ #: includes/Admin.php:1432
772
  msgid "Do not sync"
773
  msgstr ""
774
 
775
+ #: includes/Admin.php:500
776
  msgid "Filter by Facebook sync setting"
777
  msgstr ""
778
 
779
+ #: includes/Admin.php:913
780
  msgid "Include in Facebook sync"
781
  msgstr ""
782
 
783
+ #: includes/Admin.php:914
784
  msgid "Exclude from Facebook sync"
785
  msgstr ""
786
 
787
+ #: includes/Admin.php:1107
788
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
789
  #. <a> tag, %4$s - <a> tag
790
  msgid ""
798
  msgstr[0] ""
799
  msgstr[1] ""
800
 
801
+ #: includes/Admin.php:1114
802
  msgid "Don't show this notice again"
803
  msgstr ""
804
 
805
+ #: includes/Admin.php:1148
806
  #. translators: Placeholders: %1$s - number of affected products, %2$s opening
807
  #. HTML <a> tag, %3$s - closing HTML </a> tag, %4$s - opening HTML <a> tag,
808
  #. %5$s - closing HTML </a> tag
819
  msgstr[0] ""
820
  msgstr[1] ""
821
 
822
+ #: includes/Admin.php:1214
823
  #. translators: Placeholders: %1$s - opening HTML <strong> tag, %2$s - closing
824
  #. HTML </strong> tag, %3$s - opening HTML <a> tag, %4$s - closing HTML </a>
825
  #. tag
829
  "your Facebook catalog. You may still advertise Virtual products on Facebook."
830
  msgstr ""
831
 
832
+ #: includes/Admin.php:1288 includes/Admin.php:1430
833
  msgid "Sync and show in catalog"
834
  msgstr ""
835
 
836
+ #: includes/Admin.php:1289 includes/Admin.php:1431
837
  msgid "Sync and hide in catalog"
838
  msgstr ""
839
 
840
+ #: includes/Admin.php:1299 includes/Admin.php:1444
841
  msgid "Facebook Description"
842
  msgstr ""
843
 
844
+ #: includes/Admin.php:1301 includes/Admin.php:1446
845
  msgid ""
846
  "Custom (plain-text only) description for product on Facebook. If blank, "
847
  "product description will be used. If product description is blank, "
848
  "shortname will be used."
849
  msgstr ""
850
 
851
+ #: includes/Admin.php:1312 includes/Admin.php:1459
852
  msgid "Facebook Product Image"
853
  msgstr ""
854
 
855
+ #: includes/Admin.php:1314 includes/Admin.php:1461
856
  msgid ""
857
  "Choose the product image that should be synced to the Facebook catalog for "
858
  "this product. If using a custom image, please enter an absolute URL (e.g. "
859
  "https://domain.com/image.jpg)."
860
  msgstr ""
861
 
862
+ #: includes/Admin.php:1316
863
  msgid "Use WooCommerce image"
864
  msgstr ""
865
 
866
+ #: includes/Admin.php:1317 includes/Admin.php:1465
867
  msgid "Use custom image"
868
  msgstr ""
869
 
870
+ #: includes/Admin.php:1328 includes/Admin.php:1477
871
  msgid "Custom Image URL"
872
  msgstr ""
873
 
874
+ #: includes/Admin.php:1339 includes/Admin.php:1490
875
  #. translators: Placeholders %1$s - WC currency symbol
876
  msgid "Facebook Price (%1$s)"
877
  msgstr ""
878
 
879
+ #: includes/Admin.php:1343 includes/Admin.php:1494
880
  msgid ""
881
  "Custom price for product on Facebook. Please enter in monetary decimal (.) "
882
  "format without thousand separators and currency symbols. If blank, product "
883
  "price will be used."
884
  msgstr ""
885
 
886
+ #: includes/Admin.php:1463
887
  msgid "Use variation image"
888
  msgstr ""
889
 
890
+ #: includes/Admin.php:1464
891
  msgid "Use parent image"
892
  msgstr ""
893
 
894
+ #: includes/Admin.php:1618
895
  msgid "Close modal panel"
896
  msgstr ""
897
 
includes/Admin.php CHANGED
@@ -200,6 +200,7 @@ class Admin {
200
  'enhanced_attribute_page_type_edit_category' => \SkyVerge\WooCommerce\Facebook\Admin\Enhanced_Catalog_Attribute_Fields::PAGE_TYPE_EDIT_CATEGORY,
201
  'enhanced_attribute_page_type_add_category' => \SkyVerge\WooCommerce\Facebook\Admin\Enhanced_Catalog_Attribute_Fields::PAGE_TYPE_ADD_CATEGORY,
202
  'enhanced_attribute_page_type_edit_product' => \SkyVerge\WooCommerce\Facebook\Admin\Enhanced_Catalog_Attribute_Fields::PAGE_TYPE_EDIT_PRODUCT,
 
203
  'is_sync_enabled_for_product' => $this->is_sync_enabled_for_current_product(),
204
  'set_product_visibility_nonce' => wp_create_nonce( 'set-products-visibility' ),
205
  'set_product_sync_prompt_nonce' => wp_create_nonce( 'set-product-sync-prompt' ),
@@ -264,6 +265,24 @@ class Admin {
264
  return Products::is_sync_enabled_for_product( $product );
265
  }
266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
 
268
  /**
269
  * Gets the markup for the message used in the product not ready modal.
200
  'enhanced_attribute_page_type_edit_category' => \SkyVerge\WooCommerce\Facebook\Admin\Enhanced_Catalog_Attribute_Fields::PAGE_TYPE_EDIT_CATEGORY,
201
  'enhanced_attribute_page_type_add_category' => \SkyVerge\WooCommerce\Facebook\Admin\Enhanced_Catalog_Attribute_Fields::PAGE_TYPE_ADD_CATEGORY,
202
  'enhanced_attribute_page_type_edit_product' => \SkyVerge\WooCommerce\Facebook\Admin\Enhanced_Catalog_Attribute_Fields::PAGE_TYPE_EDIT_PRODUCT,
203
+ 'is_product_published' => $this->is_current_product_published(),
204
  'is_sync_enabled_for_product' => $this->is_sync_enabled_for_current_product(),
205
  'set_product_visibility_nonce' => wp_create_nonce( 'set-products-visibility' ),
206
  'set_product_sync_prompt_nonce' => wp_create_nonce( 'set-product-sync-prompt' ),
265
  return Products::is_sync_enabled_for_product( $product );
266
  }
267
 
268
+ /**
269
+ * Determines whether the current product is published.
270
+ *
271
+ * @since 2.6.15
272
+ *
273
+ * @return bool
274
+ */
275
+ private function is_current_product_published() {
276
+ global $post;
277
+
278
+ $product = wc_get_product( $post );
279
+
280
+ if ( ! $product instanceof \WC_Product ) {
281
+ return false;
282
+ }
283
+
284
+ return 'publish' === $product->get_status();
285
+ }
286
 
287
  /**
288
  * Gets the markup for the message used in the product not ready modal.
includes/Products.php CHANGED
@@ -281,7 +281,7 @@ class Products {
281
  * @since 1.10.0
282
  *
283
  * @param \WC_Product $product product object
284
- * @param bool $visibility true for 'published' or false for 'staging'
285
  * @return bool success
286
  */
287
  public static function set_product_visibility( \WC_Product $product, $visibility ) {
281
  * @since 1.10.0
282
  *
283
  * @param \WC_Product $product product object
284
+ * @param bool $visibility true for 'published' or false for 'hidden'
285
  * @return bool success
286
  */
287
  public static function set_product_visibility( \WC_Product $product, $visibility ) {
includes/fbproduct.php CHANGED
@@ -354,17 +354,14 @@ if ( ! class_exists( 'WC_Facebook_Product' ) ) :
354
  return $description;
355
  }
356
 
 
 
 
 
 
 
357
  public function add_sale_price( $product_data, $for_items_batch = false ) {
358
 
359
- // initialise sale price
360
- if ( $for_items_batch ) {
361
- $product_data['sale_price_effective_date'] = self::MIN_DATE_1 . self::MIN_TIME . '/' . self::MIN_DATE_2 . self::MAX_TIME;
362
- } else {
363
- $product_data['sale_price_start_date'] = self::MIN_DATE_1 . self::MIN_TIME;
364
- $product_data['sale_price_end_date'] = self::MIN_DATE_2 . self::MAX_TIME;
365
- }
366
- $product_data['sale_price'] = $product_data['price'];
367
-
368
  $sale_price = $this->woo_product->get_sale_price();
369
 
370
  // check if sale exist
@@ -630,7 +627,7 @@ if ( ! class_exists( 'WC_Facebook_Product' ) ) :
630
  $product_data['checkout_url'] = $checkout_url;
631
  }
632
 
633
- // IF using WPML, set the product to staging unless it is in the
634
  // default language. WPML >= 3.2 Supported.
635
  if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
636
  if ( class_exists( 'WC_Facebook_WPML_Injector' ) && WC_Facebook_WPML_Injector::should_hide( $id ) ) {
354
  return $description;
355
  }
356
 
357
+ /**
358
+ * @param array $product_data
359
+ * @param bool $for_items_batch
360
+ *
361
+ * @return array
362
+ */
363
  public function add_sale_price( $product_data, $for_items_batch = false ) {
364
 
 
 
 
 
 
 
 
 
 
365
  $sale_price = $this->woo_product->get_sale_price();
366
 
367
  // check if sale exist
627
  $product_data['checkout_url'] = $checkout_url;
628
  }
629
 
630
+ // IF using WPML, set the product to hidden unless it is in the
631
  // default language. WPML >= 3.2 Supported.
632
  if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
633
  if ( class_exists( 'WC_Facebook_WPML_Injector' ) && WC_Facebook_WPML_Injector::should_hide( $id ) ) {
includes/fbproductfeed.php CHANGED
@@ -569,6 +569,17 @@ if ( ! class_exists( 'WC_Facebook_Product_Feed' ) ) :
569
  $product_data['visibility'] = \WC_Facebookcommerce_Integration::FB_SHOP_PRODUCT_HIDDEN;
570
  }
571
 
 
 
 
 
 
 
 
 
 
 
 
572
  return $product_data['retailer_id'] . ',' .
573
  static::format_string_for_feed( static::get_value_from_product_data( $product_data, 'name' ) ) . ',' .
574
  static::format_string_for_feed( static::get_value_from_product_data( $product_data, 'description' ) ) . ',' .
@@ -584,12 +595,8 @@ if ( ! class_exists( 'WC_Facebook_Product_Feed' ) ) :
584
  $item_group_id . ',' .
585
  static::get_value_from_product_data( $product_data, 'checkout_url' ) . ',' .
586
  static::format_additional_image_url( static::get_value_from_product_data( $product_data, 'additional_image_urls' ) ) . ',' .
587
- static::get_value_from_product_data( $product_data, 'sale_price_start_date' ) . '/' .
588
- static::get_value_from_product_data( $product_data, 'sale_price_end_date' ) . ',' .
589
- static::format_price_for_feed(
590
- static::get_value_from_product_data( $product_data, 'sale_price', 0 ),
591
- static::get_value_from_product_data( $product_data, 'currency' )
592
- ) . ',' .
593
  'new' . ',' .
594
  static::get_value_from_product_data( $product_data, 'visibility' ) . ',' .
595
  static::get_value_from_product_data( $product_data, 'gender' ) . ',' .
569
  $product_data['visibility'] = \WC_Facebookcommerce_Integration::FB_SHOP_PRODUCT_HIDDEN;
570
  }
571
 
572
+ // Sale price, only format if we have a sale price set for the product, else leave as empty ('').
573
+ $sale_price = static::get_value_from_product_data( $product_data, 'sale_price', '' );
574
+ $sale_price_effective_date = '';
575
+ if ( is_numeric( $sale_price ) && $sale_price > 0 ) {
576
+ $sale_price_effective_date = static::get_value_from_product_data( $product_data, 'sale_price_start_date' ) . '/' . $this->get_value_from_product_data( $product_data, 'sale_price_end_date' );
577
+ $sale_price = static::format_price_for_feed(
578
+ $sale_price,
579
+ static::get_value_from_product_data( $product_data, 'currency' )
580
+ );
581
+ }
582
+
583
  return $product_data['retailer_id'] . ',' .
584
  static::format_string_for_feed( static::get_value_from_product_data( $product_data, 'name' ) ) . ',' .
585
  static::format_string_for_feed( static::get_value_from_product_data( $product_data, 'description' ) ) . ',' .
595
  $item_group_id . ',' .
596
  static::get_value_from_product_data( $product_data, 'checkout_url' ) . ',' .
597
  static::format_additional_image_url( static::get_value_from_product_data( $product_data, 'additional_image_urls' ) ) . ',' .
598
+ $sale_price_effective_date . ',' .
599
+ $sale_price . ',' .
 
 
 
 
600
  'new' . ',' .
601
  static::get_value_from_product_data( $product_data, 'visibility' ) . ',' .
602
  static::get_value_from_product_data( $product_data, 'gender' ) . ',' .
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.9
6
- Stable tag: 2.6.14
7
  Requires PHP: 5.6 or greater
8
  MySQL: 5.6 or greater
9
  License: GPLv2 or later
@@ -39,7 +39,14 @@ When opening a bug on GitHub, please give us as many details as possible.
39
 
40
  == Changelog ==
41
 
42
- = 2.6.14 - 2022-05-18 =
 
 
 
 
 
 
 
43
  * Fix - Non-latin custom product attribute names sync.
44
  * Fix - Syncing brand FB attribute instead of the website name.
45
  * Fix - Trigger InitiateCheckout event when site uses checkout block.
3
  Tags: facebook, shop, catalog, advertise, pixel, product
4
  Requires at least: 4.4
5
  Tested up to: 5.9
6
+ Stable tag: 2.6.15
7
  Requires PHP: 5.6 or greater
8
  MySQL: 5.6 or greater
9
  License: GPLv2 or later
39
 
40
  == Changelog ==
41
 
42
+ = 2.6.15 - 2022-06-01 =
43
+ * Fix - Do not set `sale_price` when the product is not on sale.
44
+ * Fix - FB Pixel is missing some ajax Add to cart events.
45
+ * Fix - Feed visibility field value for hidden items.
46
+ * Fix - Wrong Value Field in AddToCart Events.
47
+ * Tweak - Not show the removed from sync confirm modal for unpublished products.
48
+
49
+ = 2.6.14 - 2022-05-18 =
50
  * Fix - Non-latin custom product attribute names sync.
51
  * Fix - Syncing brand FB attribute instead of the website name.
52
  * Fix - Trigger InitiateCheckout event when site uses checkout block.
vendor/autoload.php CHANGED
@@ -2,6 +2,11 @@
2
 
3
  // autoload.php @generated by Composer
4
 
 
 
 
 
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInitc9664324ae539b90345f70ed310cb589::getLoader();
2
 
3
  // autoload.php @generated by Composer
4
 
5
+ if (PHP_VERSION_ID < 50600) {
6
+ echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
7
+ exit(1);
8
+ }
9
+
10
  require_once __DIR__ . '/composer/autoload_real.php';
11
 
12
+ return ComposerAutoloaderInite6107a0cd9da0d96466f317553205981::getLoader();
vendor/composer/ClassLoader.php CHANGED
@@ -149,7 +149,7 @@ class ClassLoader
149
 
150
  /**
151
  * @return string[] Array of classname => path
152
- * @psalm-var array<string, string>
153
  */
154
  public function getClassMap()
155
  {
149
 
150
  /**
151
  * @return string[] Array of classname => path
152
+ * @psalm-return array<string, string>
153
  */
154
  public function getClassMap()
155
  {
vendor/composer/InstalledVersions.php CHANGED
@@ -21,11 +21,26 @@ use Composer\Semver\VersionParser;
21
  * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
22
  *
23
  * To require its presence, you can require `composer-runtime-api ^2.0`
 
 
24
  */
25
  class InstalledVersions
26
  {
 
 
 
 
27
  private static $installed;
 
 
 
 
28
  private static $canGetVendors;
 
 
 
 
 
29
  private static $installedByVendor = array();
30
 
31
  /**
21
  * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
22
  *
23
  * To require its presence, you can require `composer-runtime-api ^2.0`
24
+ *
25
+ * @final
26
  */
27
  class InstalledVersions
28
  {
29
+ /**
30
+ * @var mixed[]|null
31
+ * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
32
+ */
33
  private static $installed;
34
+
35
+ /**
36
+ * @var bool|null
37
+ */
38
  private static $canGetVendors;
39
+
40
+ /**
41
+ * @var array[]
42
+ * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
43
+ */
44
  private static $installedByVendor = array();
45
 
46
  /**
vendor/composer/autoload_classmap.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_classmap.php @generated by Composer
4
 
5
- $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
2
 
3
  // autoload_classmap.php @generated by Composer
4
 
5
+ $vendorDir = dirname(__DIR__);
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
vendor/composer/autoload_namespaces.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_namespaces.php @generated by Composer
4
 
5
- $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
2
 
3
  // autoload_namespaces.php @generated by Composer
4
 
5
+ $vendorDir = dirname(__DIR__);
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
vendor/composer/autoload_psr4.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_psr4.php @generated by Composer
4
 
5
- $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
2
 
3
  // autoload_psr4.php @generated by Composer
4
 
5
+ $vendorDir = dirname(__DIR__);
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInitc9664324ae539b90345f70ed310cb589
6
  {
7
  private static $loader;
8
 
@@ -24,31 +24,12 @@ class ComposerAutoloaderInitc9664324ae539b90345f70ed310cb589
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
- spl_autoload_register(array('ComposerAutoloaderInitc9664324ae539b90345f70ed310cb589', 'loadClassLoader'), true, true);
28
- self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
29
- spl_autoload_unregister(array('ComposerAutoloaderInitc9664324ae539b90345f70ed310cb589', 'loadClassLoader'));
30
-
31
- $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
32
- if ($useStaticLoader) {
33
- require __DIR__ . '/autoload_static.php';
34
-
35
- call_user_func(\Composer\Autoload\ComposerStaticInitc9664324ae539b90345f70ed310cb589::getInitializer($loader));
36
- } else {
37
- $map = require __DIR__ . '/autoload_namespaces.php';
38
- foreach ($map as $namespace => $path) {
39
- $loader->set($namespace, $path);
40
- }
41
-
42
- $map = require __DIR__ . '/autoload_psr4.php';
43
- foreach ($map as $namespace => $path) {
44
- $loader->setPsr4($namespace, $path);
45
- }
46
-
47
- $classMap = require __DIR__ . '/autoload_classmap.php';
48
- if ($classMap) {
49
- $loader->addClassMap($classMap);
50
- }
51
- }
52
 
53
  $loader->register(true);
54
 
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInite6107a0cd9da0d96466f317553205981
6
  {
7
  private static $loader;
8
 
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
+ spl_autoload_register(array('ComposerAutoloaderInite6107a0cd9da0d96466f317553205981', 'loadClassLoader'), true, true);
28
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
29
+ spl_autoload_unregister(array('ComposerAutoloaderInite6107a0cd9da0d96466f317553205981', 'loadClassLoader'));
30
+
31
+ require __DIR__ . '/autoload_static.php';
32
+ call_user_func(\Composer\Autoload\ComposerStaticInite6107a0cd9da0d96466f317553205981::getInitializer($loader));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  $loader->register(true);
35
 
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInitc9664324ae539b90345f70ed310cb589
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'S' =>
@@ -43,9 +43,9 @@ class ComposerStaticInitc9664324ae539b90345f70ed310cb589
43
  public static function getInitializer(ClassLoader $loader)
44
  {
45
  return \Closure::bind(function () use ($loader) {
46
- $loader->prefixLengthsPsr4 = ComposerStaticInitc9664324ae539b90345f70ed310cb589::$prefixLengthsPsr4;
47
- $loader->prefixDirsPsr4 = ComposerStaticInitc9664324ae539b90345f70ed310cb589::$prefixDirsPsr4;
48
- $loader->classMap = ComposerStaticInitc9664324ae539b90345f70ed310cb589::$classMap;
49
 
50
  }, null, ClassLoader::class);
51
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInite6107a0cd9da0d96466f317553205981
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'S' =>
43
  public static function getInitializer(ClassLoader $loader)
44
  {
45
  return \Closure::bind(function () use ($loader) {
46
+ $loader->prefixLengthsPsr4 = ComposerStaticInite6107a0cd9da0d96466f317553205981::$prefixLengthsPsr4;
47
+ $loader->prefixDirsPsr4 = ComposerStaticInite6107a0cd9da0d96466f317553205981::$prefixDirsPsr4;
48
+ $loader->classMap = ComposerStaticInite6107a0cd9da0d96466f317553205981::$classMap;
49
 
50
  }, null, ClassLoader::class);
51
  }
vendor/composer/installed.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php return array(
2
  'root' => array(
3
- 'pretty_version' => 'dev-release/2.6.14',
4
- 'version' => 'dev-release/2.6.14',
5
  'type' => 'wordpress-plugin',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
- 'reference' => '7367bdc89bc85a8d77552b072b94f93e1505267e',
9
  'name' => 'facebookincubator/facebook-for-woocommerce',
10
  'dev' => false,
11
  ),
@@ -20,12 +20,12 @@
20
  'dev_requirement' => false,
21
  ),
22
  'facebookincubator/facebook-for-woocommerce' => array(
23
- 'pretty_version' => 'dev-release/2.6.14',
24
- 'version' => 'dev-release/2.6.14',
25
  'type' => 'wordpress-plugin',
26
  'install_path' => __DIR__ . '/../../',
27
  'aliases' => array(),
28
- 'reference' => '7367bdc89bc85a8d77552b072b94f93e1505267e',
29
  'dev_requirement' => false,
30
  ),
31
  'roundcube/plugin-installer' => array(
1
  <?php return array(
2
  'root' => array(
3
+ 'pretty_version' => 'dev-release/2.6.15',
4
+ 'version' => 'dev-release/2.6.15',
5
  'type' => 'wordpress-plugin',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
+ 'reference' => 'f177697f5f65440b76e1992404e50ef1652a3e3d',
9
  'name' => 'facebookincubator/facebook-for-woocommerce',
10
  'dev' => false,
11
  ),
20
  'dev_requirement' => false,
21
  ),
22
  'facebookincubator/facebook-for-woocommerce' => array(
23
+ 'pretty_version' => 'dev-release/2.6.15',
24
+ 'version' => 'dev-release/2.6.15',
25
  'type' => 'wordpress-plugin',
26
  'install_path' => __DIR__ . '/../../',
27
  'aliases' => array(),
28
+ 'reference' => 'f177697f5f65440b76e1992404e50ef1652a3e3d',
29
  'dev_requirement' => false,
30
  ),
31
  'roundcube/plugin-installer' => array(