diff --git a/facebook-commerce.php b/facebook-commerce.php index d3d0e5399..c5a95c8e6 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -1171,26 +1171,6 @@ public function on_product_publish( $product_id ) { } } - /** - * If the user has opt-in to remove products that are out of stock, - * this function will delete the product from FB Page as well. - * - * @param int $wp_id - * @param WC_Product $woo_product - * - * @return bool - */ - public function delete_on_out_of_stock( int $wp_id, WC_Product $woo_product ): bool { - if ( Products::product_should_be_deleted( $woo_product ) ) { - $product = wc_get_product( $wp_id ); - $this->delete_fb_product( $product ); - - return true; - } - - return false; - } - /** * Syncs product to Facebook when saving a variable product. * @@ -1202,10 +1182,6 @@ public function on_variable_product_publish( $wp_id, $woo_product = null ) { $woo_product = new \WC_Facebook_Product( $wp_id ); } - if ( $this->delete_on_out_of_stock( $wp_id, $woo_product->woo_product ) ) { - return; - } - if ( ! $this->product_should_be_synced( $woo_product->woo_product ) ) { return; } @@ -1226,7 +1202,7 @@ public function on_variable_product_publish( $wp_id, $woo_product = null ) { // scheduled update for each variation that should be synced foreach ( $woo_product->get_children() as $variation_id ) { $variation = wc_get_product( $variation_id ); - if ( $variation instanceof WC_Product && $this->product_should_be_synced( $variation ) && ! $this->delete_on_out_of_stock( $variation_id, $variation ) ) { + if ( $variation instanceof WC_Product && $this->product_should_be_synced( $variation ) ) { $variation_ids[] = $variation_id; } } @@ -1248,10 +1224,6 @@ public function on_simple_product_publish( $wp_id, $woo_product = null, &$parent $woo_product = new \WC_Facebook_Product( $wp_id, $parent_product ); } - if ( $this->delete_on_out_of_stock( $wp_id, $woo_product->woo_product ) ) { - return; - } - if ( ! $this->product_should_be_synced( $woo_product->woo_product ) ) { return; } diff --git a/tests/Unit/WCFacebookCommerceIntegrationTest.php b/tests/Unit/WCFacebookCommerceIntegrationTest.php index 4b04ccde2..daa43229a 100644 --- a/tests/Unit/WCFacebookCommerceIntegrationTest.php +++ b/tests/Unit/WCFacebookCommerceIntegrationTest.php @@ -875,67 +875,7 @@ public function test_on_product_publish_variable_product() { $this->integration->on_product_publish( $product->get_id() ); } - - /** - * Sunny day test. Tests deletion of out of stock simple product item. - * - * @return void - */ - public function test_delete_on_out_of_stock_deletes_simple_product() { - $product = WC_Helper_Product::create_simple_product(); - - update_option( 'woocommerce_hide_out_of_stock_items', 'yes' ); - $product->set_stock_status( 'outofstock' ); - - add_post_meta( $product->get_id(), WC_Facebookcommerce_Integration::FB_PRODUCT_ITEM_ID, 'facebook-product-item-id' ); - - $this->api->expects( $this->never() ) - ->method( 'delete_product_item' ) - ->with( 'facebook-product-item-id' ); - - $result = $this->integration->delete_on_out_of_stock( $product->get_id(), $product ); - - $this->assertFalse( $result ); - } - - /** - * Tests deletion of out of stock simple product item not performed due to WC settings set to 'no'. - * - * @return void - */ - public function test_delete_on_out_of_stock_does_not_delete_simple_product_with_wc_settings_off() { - $product = WC_Helper_Product::create_simple_product(); - - update_option( 'woocommerce_hide_out_of_stock_items', 'no' ); - $product->set_stock_status( 'outofstock' ); - - $this->api->expects( $this->never() ) - ->method( 'delete_product_item' ); - - $result = $this->integration->delete_on_out_of_stock( $product->get_id(), $product ); - - $this->assertFalse( $result ); - } - - /** - * Tests deletion of in-stock variation product item not performed. - * - * @return void - */ - public function test_delete_on_out_of_stock_does_not_delete_in_stock_simple_product() { - $product = WC_Helper_Product::create_variation_product(); - - update_option( 'woocommerce_hide_out_of_stock_items', 'yes' ); - $product->set_stock_status( 'instock' ); - - $this->api->expects( $this->never() ) - ->method( 'delete_product_item' ); - - $result = $this->integration->delete_on_out_of_stock( $product->get_id(), $product ); - - $this->assertFalse( $result ); - } - + /** * Tests update of existing variable product. *