diff --git a/assets/js/admin/plugin-rendering.js b/assets/js/admin/plugin-rendering.js index 02865880b..cb9ca27d2 100644 --- a/assets/js/admin/plugin-rendering.js +++ b/assets/js/admin/plugin-rendering.js @@ -7,7 +7,6 @@ * @package FacebookCommerce */ - jQuery( document ).ready( function( $ ) { //Setting up opt out modal let modal; diff --git a/assets/js/admin/products-admin.js b/assets/js/admin/products-admin.js index 992832998..0eb249620 100644 --- a/assets/js/admin/products-admin.js +++ b/assets/js/admin/products-admin.js @@ -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. * @@ -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 ) ); diff --git a/facebook-commerce.php b/facebook-commerce.php index c955e9f55..07347f258 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -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) []; } /** @@ -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 ************************************************************************************************/ diff --git a/includes/Admin.php b/includes/Admin.php index fcd929923..3c396bbd5 100644 --- a/includes/Admin.php +++ b/includes/Admin.php @@ -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 @@ -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() ) ); } } } diff --git a/includes/ProductSync/ProductValidator.php b/includes/ProductSync/ProductValidator.php index 76563d4d8..3a617b0a1 100644 --- a/includes/ProductSync/ProductValidator.php +++ b/includes/ProductSync/ProductValidator.php @@ -120,7 +120,6 @@ public function validate() { $this->validate_product_sync_field(); $this->validate_product_status(); $this->validate_product_visibility(); - $this->validate_product_terms(); } /** @@ -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(); } /** @@ -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(); } /** @@ -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. * @@ -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). * diff --git a/includes/Products.php b/includes/Products.php index ffb040fc3..a5d237000 100644 --- a/includes/Products.php +++ b/includes/Products.php @@ -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. * @@ -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. * diff --git a/includes/Products/Stock.php b/includes/Products/Stock.php index 917bc4946..9ed952685 100644 --- a/includes/Products/Stock.php +++ b/includes/Products/Stock.php @@ -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() ) ); } } diff --git a/includes/Products/Sync/Background.php b/includes/Products/Sync/Background.php index 5b22317e4..115c7b816 100644 --- a/includes/Products/Sync/Background.php +++ b/includes/Products/Sync/Background.php @@ -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 ); diff --git a/includes/fbproductfeed.php b/includes/fbproductfeed.php index 38c293eb2..5549b68f1 100644 --- a/includes/fbproductfeed.php +++ b/includes/fbproductfeed.php @@ -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 = ''; diff --git a/tests/Unit/WCFacebookCommerceIntegrationTest.php b/tests/Unit/WCFacebookCommerceIntegrationTest.php index 488fb57b1..0591659dc 100644 --- a/tests/Unit/WCFacebookCommerceIntegrationTest.php +++ b/tests/Unit/WCFacebookCommerceIntegrationTest.php @@ -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 ); } /** @@ -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 ); } /** @@ -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 ); } /** @@ -2154,7 +2157,7 @@ function ( $ids ) { $tags = $this->integration->get_excluded_product_tag_ids(); - $this->assertEquals( [ 111, 222, 333 ], $tags ); + $this->assertEquals( [ ], $tags ); }