Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 0 additions & 24 deletions facebook-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
*
Expand Down
14 changes: 0 additions & 14 deletions includes/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
23 changes: 0 additions & 23 deletions includes/API/ProductCatalog/ProductGroups/Delete/Request.php

This file was deleted.

16 changes: 0 additions & 16 deletions includes/API/ProductCatalog/ProductGroups/Delete/Response.php

This file was deleted.

6 changes: 1 addition & 5 deletions includes/Jobs/DeleteProductsFromFBCatalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
27 changes: 0 additions & 27 deletions tests/Unit/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/WCFacebookCommerceIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() );

Expand Down