Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
88a5954
Adding plugin version logic
SayanPandey May 8, 2025
a0209a5
Adding a dummy banner
SayanPandey May 15, 2025
1e724d8
Adding custom action to link JS to PHP code
SayanPandey May 16, 2025
325b81d
Moving the add actions to addHooks()
SayanPandey May 19, 2025
695f4b9
registering new plugin update script
SayanPandey May 20, 2025
94e1472
Adding functional back and forth js-php connection vaia ajax url
SayanPandey May 20, 2025
67606f8
Addin opt out and opt in banner with refresh
SayanPandey May 20, 2025
9039db3
Finalizing the opt out experience except the links and proper version
SayanPandey May 20, 2025
00d3238
Adding opt out approach
SayanPandey May 20, 2025
512072f
Adding phpcs fix
SayanPandey May 20, 2025
8ec1edc
Adding upgrade banner
SayanPandey May 21, 2025
2c9d33d
Testing plugin version update flow
SayanPandey May 21, 2025
44d8c40
Adding fallbacks for upgrade
SayanPandey May 21, 2025
e6cafff
Adding last set of banners
SayanPandey May 21, 2025
f10ae1d
Added final banner
SayanPandey May 22, 2025
cb42f6a
Added the modal
SayanPandey May 22, 2025
1a8427e
Adding phpcs fixes
SayanPandey May 22, 2025
a1335af
Adding phpcs fixes
SayanPandey May 22, 2025
5467c03
Fixing plugin diff comments
SayanPandey May 23, 2025
08292e9
Removing plugin upgrade code
SayanPandey May 23, 2025
99b0fdf
Adding timeout on banner close
SayanPandey May 23, 2025
dd17a54
Making phpcs fixes
SayanPandey May 23, 2025
1583285
Renaming plugin update to plugin rendering js
SayanPandey May 23, 2025
668c7b9
Renaming it to PluginUpdate.php
SayanPandey May 23, 2025
7982bca
making the latest changes with all renaming
SayanPandey May 24, 2025
68c0ed0
Fixing diff comments
SayanPandey May 24, 2025
2a00a9c
Adding test fixes
SayanPandey May 25, 2025
c189680
Fixing diff comments
SayanPandey May 27, 2025
3dc856a
Removing bulk action validation, dead code and toggle when excluded c…
SayanPandey May 26, 2025
a2d9ba0
Removing all the useless product exclusion and stock related stuff
SayanPandey May 26, 2025
f5b6412
Nullifying excluded categories and taga
SayanPandey May 26, 2025
48ccfa4
Resolving all the tests based on excluded categories and tags
SayanPandey May 26, 2025
a5abf90
Removing a space to activate the rebase
SayanPandey May 27, 2025
2879446
Adding some phpcs fixes
SayanPandey May 29, 2025
45b7451
Removing the code that disables the commerce settings
SayanPandey May 31, 2025
8650132
Fixing diff comments 2
SayanPandey Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion assets/js/admin/plugin-rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @package FacebookCommerce
*/


jQuery( document ).ready( function( $ ) {
//Setting up opt out modal
let modal;
Expand Down
21 changes: 0 additions & 21 deletions assets/js/admin/products-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,6 @@ jQuery( document ).ready( function( $ ) {
}


/**
* Toggles (shows/hides) the visibility of Facebook Commerce setting fields.
*
* @since 2.1.0
*
* @param {boolean} enabled whether the settings fields should be enabled or not
* @param {jQuery} $container a common ancestor of all the elements that can be shown/hidden
*/
function toggleFacebookCommerceSettings( enabled, $container ) {

let $group = $container.find( '.wc-facebook-commerce-options-group' );

if ( enabled ) {
$group.show();
} else {
$group.hide();
}
}


/**
* Disables and changes the checked status of the Sell on Instagram setting field.
*
Expand Down Expand Up @@ -475,7 +455,6 @@ jQuery( document ).ready( function( $ ) {
let syncEnabled = simpleProductSyncModeSelect.val() !== 'sync_disabled';

toggleFacebookSettings( syncEnabled, facebookSettingsPanel );
toggleFacebookCommerceSettings( syncEnabled, facebookSettingsPanel );

if ( syncEnabled ) {
removeProductIDFromUnSyncList( getSyncTargetProductID( simpleProductSyncModeSelect ) );
Expand Down
11 changes: 9 additions & 2 deletions facebook-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -2451,7 +2451,11 @@ public function get_excluded_product_category_ids() {
*
* @since 1.10.0
*/
return (array) apply_filters( 'wc_facebook_excluded_product_category_ids', get_option( self::SETTING_EXCLUDED_PRODUCT_CATEGORY_IDS, [] ), $this );

// TODO: to Remove all existence of these function `get_excluded_product_category_ids` as we are no longer supporting these.
// Matter of fact it is used in multiple places including important places like Product sets tab.
// Hence providing empty array as excluded categories :)
return (array) [];
}

/**
Expand All @@ -2469,7 +2473,10 @@ public function get_excluded_product_tag_ids() {
*
* @since 1.10.0
*/
return (array) apply_filters( 'wc_facebook_excluded_product_tag_ids', get_option( self::SETTING_EXCLUDED_PRODUCT_TAG_IDS, [] ), $this );
// TODO: to Remove all existence of these function `get_excluded_product_tag_ids` as we are no longer supporting these.
// Matter of fact it is used in multiple places including important places like Product sets tab.
// Hence providing empty array as excluded tags :)
return (array) [];
}

/** Setter methods ************************************************************************************************/
Expand Down
25 changes: 1 addition & 24 deletions includes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -749,23 +749,6 @@ private function maybe_add_tax_query_for_excluded_taxonomies( $query_vars, $in =
return $query_vars;
}

/**
* Adds bulk actions in the products edit screen.
*
* @internal
*
* @since 1.10.0
*
* @param array $bulk_actions array of bulk action keys and labels
* @return array
*/
public function add_products_sync_bulk_actions( $bulk_actions ) {
$bulk_actions['facebook_include'] = __( 'Include in Facebook sync', 'facebook-for-woocommerce' );
$bulk_actions['facebook_exclude'] = __( 'Exclude from Facebook sync', 'facebook-for-woocommerce' );
return $bulk_actions;
}


/**
* Handles a Facebook product sync bulk action.
* Called every time for a product
Expand Down Expand Up @@ -859,13 +842,7 @@ private function resync_products( array $products ) {
$integration->on_product_publish( $product->get_id() );

} elseif ( $integration->product_should_be_synced( $product ) ) {

// schedule simple products to be updated or deleted from the catalog in the background
if ( Products::product_should_be_deleted( $product ) ) {
facebook_for_woocommerce()->get_products_sync_handler()->delete_products( array( $product->get_id() ) );
} else {
facebook_for_woocommerce()->get_products_sync_handler()->create_or_update_products( array( $product->get_id() ) );
}
facebook_for_woocommerce()->get_products_sync_handler()->create_or_update_products( array( $product->get_id() ) );
}
}
}
Expand Down
43 changes: 0 additions & 43 deletions includes/ProductSync/ProductValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public function validate() {
$this->validate_product_sync_field();
$this->validate_product_status();
$this->validate_product_visibility();
$this->validate_product_terms();
}

/**
Expand All @@ -133,7 +132,6 @@ public function validate() {
public function validate_but_skip_status_check() {
$this->validate_product_sync_field();
$this->validate_product_visibility();
$this->validate_product_terms();
}

/**
Expand All @@ -144,7 +142,6 @@ public function validate_but_skip_status_check() {
*/
public function validate_but_skip_sync_field() {
$this->validate_product_visibility();
$this->validate_product_terms();
}

/**
Expand All @@ -164,23 +161,6 @@ public function passes_all_checks(): bool {
return true;
}

/**
* Check if the product's terms (categories and tags) allow it to sync.
*
* @return bool
*/
public function passes_product_terms_check(): bool {
try {
$this->validate_product_terms();
} catch ( ProductExcludedException $e ) {
return false;
} catch ( ProductInvalidException $e ) {
return false;
}

return true;
}

/**
* Check if the product's product sync meta field allows it to sync.
*
Expand Down Expand Up @@ -266,29 +246,6 @@ protected function validate_product_visibility() {
}
}

/**
* Check whether the product's categories or tags (terms) exclude it from sync.
*
* @throws ProductExcludedException If product should not be synced.
*/
protected function validate_product_terms() {
$product = $this->product_parent ? $this->product_parent : $this->product;

$excluded_categories = $this->integration->get_excluded_product_category_ids();
if ( $excluded_categories ) {
if ( ! empty( array_intersect( $product->get_category_ids(), $excluded_categories ) ) ) {
throw new ProductExcludedException( __( 'Product excluded because of categories.', 'facebook-for-woocommerce' ) );
}
}

$excluded_tags = $this->integration->get_excluded_product_tag_ids();
if ( $excluded_tags ) {
if ( ! empty( array_intersect( $product->get_tag_ids(), $excluded_tags ) ) ) {
throw new ProductExcludedException( __( 'Product excluded because of tags.', 'facebook-for-woocommerce' ) );
}
}
}

/**
* Validate if the product is excluded from at the "product level" (product meta value).
*
Expand Down
33 changes: 0 additions & 33 deletions includes/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,23 +206,6 @@ public static function published_product_should_be_synced( \WC_Product $product
}
}


/**
* Determines whether the given product should be removed from the catalog.
*
* A product should be removed if it is no longer in stock and the user has opted-in to hide products that are out of stock,
* or belongs to an excluded category.
*
* @since 2.0.0
*
* @param \WC_Product $product
* @return bool
*/
public static function product_should_be_deleted( \WC_Product $product ) {
return ! facebook_for_woocommerce()->get_product_sync_validator( $product )->passes_product_terms_check();
}


/**
* Determines whether a product is enabled to be synced in Facebook.
*
Expand All @@ -240,22 +223,6 @@ public static function is_sync_enabled_for_product( \WC_Product $product ) {
return facebook_for_woocommerce()->get_product_sync_validator( $product )->passes_product_sync_field_check();
}


/**
* Determines whether the product's terms would make it excluded to be synced from Facebook.
*
* @since 1.10.0
*
* @deprecated use \WooCommerce\Facebook\ProductSync\ProductValidator::passes_product_terms_check() instead
*
* @param \WC_Product $product product object
* @return bool if true, product should be excluded from sync, if false, product can be included in sync (unless manually excluded by individual product meta)
*/
public static function is_sync_excluded_for_product_terms( \WC_Product $product ) {
return ! facebook_for_woocommerce()->get_product_sync_validator( $product )->passes_product_terms_check();
}


/**
* Sets a product's visibility in the Facebook shop.
*
Expand Down
8 changes: 1 addition & 7 deletions includes/Products/Stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,13 @@ function ( $item ) {


/**
* Schedules a product sync to update the product's stock status.
*
* The product is removed from Facebook if it is out of stock and the plugin is configured to remove out of stock products from the catalog.
* Schedules a product sync to update the product's stock status
*
* @since 2.0.5
*
* @param \WC_Product $product a product object
*/
private function maybe_sync_product_stock_status( \WC_Product $product ) {
if ( Products::product_should_be_deleted( $product ) ) {
facebook_for_woocommerce()->get_integration()->delete_fb_product( $product );
return;
}
facebook_for_woocommerce()->get_products_sync_handler()->create_or_update_products( array( $product->get_id() ) );
}
}
2 changes: 1 addition & 1 deletion includes/Products/Sync/Background.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private function process_item_update( $prefixed_product_id ) {
}

$request = null;
if ( ! Products::product_should_be_deleted( $product ) && Products::product_should_be_synced( $product ) ) {
if ( Products::product_should_be_synced( $product ) ) {

if ( $product->is_type( 'variation' ) ) {
$product_data = \WC_Facebookcommerce_Utils::prepare_product_variation_data_items_batch( $product );
Expand Down
7 changes: 1 addition & 6 deletions includes/fbproductfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,7 @@ private function prepare_product_for_feed( $woo_product, &$attribute_variants )

$product_data['default_product'] = '';
}

// when dealing with the feed file, only set out-of-stock products as hidden
if ( Products::product_should_be_deleted( $woo_product->woo_product ) ) {
$product_data['visibility'] = \WC_Facebookcommerce_Integration::FB_SHOP_PRODUCT_HIDDEN;
}


// Sale price, only format if we have a sale price set for the product, else leave as empty ('').
$sale_price = static::get_value_from_product_data( $product_data, 'sale_price', '' );
$sale_price_effective_date = '';
Expand Down
11 changes: 7 additions & 4 deletions tests/Unit/WCFacebookCommerceIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2077,7 +2077,8 @@ public function test_get_excluded_product_category_ids_no_filter() {

$categories = $this->integration->get_excluded_product_category_ids();

$this->assertEquals( [ 121, 221, 321, 421, 521, 621 ], $categories );
// Empty array will be retured as there is no longer support for excluded categories
$this->assertEquals( [ ], $categories );
}

/**
Expand All @@ -2100,7 +2101,8 @@ function ( $ids ) {

$categories = $this->integration->get_excluded_product_category_ids();

$this->assertEquals( [ 111, 222, 333 ], $categories );
// Empty array will be retured as there is no longer support for excluded categories
$this->assertEquals( [ ], $categories );
}

/**
Expand Down Expand Up @@ -2131,7 +2133,8 @@ public function test_get_excluded_product_tag_ids_no_filter() {

$tags = $this->integration->get_excluded_product_tag_ids();

$this->assertEquals( [ 121, 221, 321, 421, 521, 621 ], $tags );
// Empty array will be retured as there is no longer support for excluded tags
$this->assertEquals( [ ], $tags );
}

/**
Expand All @@ -2154,7 +2157,7 @@ function ( $ids ) {

$tags = $this->integration->get_excluded_product_tag_ids();

$this->assertEquals( [ 111, 222, 333 ], $tags );
$this->assertEquals( [ ], $tags );
}


Expand Down