diff --git a/facebook-commerce.php b/facebook-commerce.php index ae1f30497..f67d4a224 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -1037,11 +1037,9 @@ public function delete_fb_product( $product ) { } // enqueue variations to be deleted in the background $this->facebook_for_woocommerce->get_products_sync_handler()->delete_products( $retailer_ids ); - $this->delete_product_group( $product_id ); } else { $this->delete_product_item( $product_id ); - $this->delete_product_group( $product_id ); } // clear out both item and group IDs @@ -2946,28 +2944,6 @@ public function delete_product_item( int $wp_id ): void { } } - /** - * Uses the Graph API to delete the Product Group associated with the given product. - * - * @param int $product_id product ID - * - * @since 2.0.0 - * - */ - public function delete_product_group( int $product_id ) { - $product_group_id = $this->get_product_fbid( self::FB_PRODUCT_GROUP_ID, $product_id ); - if ( $product_group_id ) { - // TODO: replace with a call to API::delete_product_group() {WV 2020-05-26} - try { - $pg_result = $this->facebook_for_woocommerce->get_api()->delete_product_group( $product_group_id ); - WC_Facebookcommerce_Utils::log_with_debug_mode_enabled( $pg_result ); - } catch ( ApiException $e ) { - $message = sprintf( 'There was an error trying to delete a product group: %s', $e->getMessage() ); - WC_Facebookcommerce_Utils::log_with_debug_mode_enabled( $message ); - } - } - } - /** * Filter function for woocommerce_duplicate_product_exclude_meta filter. * diff --git a/includes/API.php b/includes/API.php index b1068e8a4..b7b0f7947 100644 --- a/includes/API.php +++ b/includes/API.php @@ -384,20 +384,6 @@ public function update_product_group( string $product_group_id, array $data ): A } - /** - * Deletes a Facebook Product Group object. - * - * @param string $product_group_id Facebook Product Group ID. - * @return API\ProductCatalog\ProductGroups\Delete\Response - * @throws ApiException - */ - public function delete_product_group( string $product_group_id ): API\ProductCatalog\ProductGroups\Delete\Response { - $request = new API\ProductCatalog\ProductGroups\Delete\Request( $product_group_id ); - $this->set_response_handler( API\ProductCatalog\ProductGroups\Delete\Response::class ); - return $this->perform_request( $request ); - } - - /** * Gets a list of Product Items in the given Product Group. * diff --git a/includes/API/ProductCatalog/ProductGroups/Delete/Request.php b/includes/API/ProductCatalog/ProductGroups/Delete/Request.php deleted file mode 100644 index 1a82afb0e..000000000 --- a/includes/API/ProductCatalog/ProductGroups/Delete/Request.php +++ /dev/null @@ -1,23 +0,0 @@ - Product Groups > Delete Graph Api. - * - * @link https://developers.facebook.com/docs/marketing-api/reference/product-catalog/product_groups/ - */ -class Request extends ApiRequest { - - /** - * @param string $product_group_id Facebook Product Group ID. - */ - public function __construct( string $product_group_id ) { - parent::__construct( "/{$product_group_id}?deletion_method=delete_items", 'DELETE' ); - } -} diff --git a/includes/API/ProductCatalog/ProductGroups/Delete/Response.php b/includes/API/ProductCatalog/ProductGroups/Delete/Response.php deleted file mode 100644 index 68ad7585d..000000000 --- a/includes/API/ProductCatalog/ProductGroups/Delete/Response.php +++ /dev/null @@ -1,16 +0,0 @@ - Product Groups > Delete Graph Api. - * - * @link https://developers.facebook.com/docs/marketing-api/reference/product-group/#Deleting - * @property-read bool $success - */ -class Response extends ApiResponse {} diff --git a/includes/Jobs/DeleteProductsFromFBCatalog.php b/includes/Jobs/DeleteProductsFromFBCatalog.php index f27f474a2..b2db9660f 100644 --- a/includes/Jobs/DeleteProductsFromFBCatalog.php +++ b/includes/Jobs/DeleteProductsFromFBCatalog.php @@ -75,11 +75,7 @@ protected function process_items( array $items, array $args ) { foreach ( $items as $product_id ) { $product = wc_get_product( $product_id ); // check if variable product - if ( $product->is_type( 'variable' ) ) { - $integration->delete_product_group( $product_id ); - } else { - $integration->delete_product_item( $product_id ); - } + $integration->delete_product_item( $product_id ); // Reset product. $integration->reset_single_product( $product_id ); diff --git a/tests/Unit/ApiTest.php b/tests/Unit/ApiTest.php index a84703fd9..8981beea3 100644 --- a/tests/Unit/ApiTest.php +++ b/tests/Unit/ApiTest.php @@ -362,33 +362,6 @@ public function test_update_product_group_preforms_update_product_group_request( $this->assertTrue( $response->success ); } - /** - * Tests delete product group prepares a request to Facebook. - * - * @return void - * @throws ApiException In case of network request error. - */ - public function test_delete_product_group_deletes_product_group_request() { - $facebook_product_group_id = '5427299404026432'; - - $response = function( $result, $parsed_args, $url ) use ( $facebook_product_group_id ) { - $this->assertEquals( 'DELETE', $parsed_args['method'] ); - $this->assertEquals( "{$this->endpoint}{$this->version}/{$facebook_product_group_id}?deletion_method=delete_items", $url ); - return [ - 'body' => '{"success":true}', - 'response' => [ - 'code' => 200, - 'message' => 'OK', - ], - ]; - }; - $this->add_filter_with_safe_teardown( 'pre_http_request', $response, 10, 3 ); - - $response = $this->api->delete_product_group( $facebook_product_group_id ); - - $this->assertTrue( $response->success ); - } - /** * Tests get product group products prepares a request to Facebook. * diff --git a/tests/Unit/WCFacebookCommerceIntegrationTest.php b/tests/Unit/WCFacebookCommerceIntegrationTest.php index 0c41da0dc..a4ee1584f 100644 --- a/tests/Unit/WCFacebookCommerceIntegrationTest.php +++ b/tests/Unit/WCFacebookCommerceIntegrationTest.php @@ -665,9 +665,6 @@ public function test_on_product_delete_simple_product() { $this->api->expects( $this->once() ) ->method( 'delete_product_item' ) ->with( 'facebook-product-id' ); - $this->api->expects( $this->once() ) - ->method( 'delete_product_group' ) - ->with( 'facebook-product-group-id' ); $this->integration->on_product_delete( $product_to_delete->get_id() );