| @@ -44,13 +44,8 @@ | ||
| 44 | 44 | if ( '' === $import_id || '' === $import_source ) { |
| 45 | 45 | return false; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - // Bulk revert passes plugin slugs from the revert table; UI passes display labels. | |
| 49 | - if ( isset( Setting_Enum::SUPPORT_IMPORT_PLUGINS[ $import_source ] ) ) { | |
| 50 | - $import_source = Setting_Enum::SUPPORT_IMPORT_PLUGINS[ $import_source ]; | |
| 51 | - } | |
| 52 | - | |
| 53 | 48 | if ( 'AAWP' === $import_source && 'aawp_list' === $post_type ) { |
| 54 | 49 | $aawp_list = $lasso_db->get_aawp_list( $import_id ); |
| 55 | 50 | $aawp_amazon_ids = $aawp_list->product_asins ?? ''; |
| 56 | 51 | $aawp_amazon_ids = '' !== $aawp_amazon_ids ? explode( ',', $aawp_amazon_ids ) : array(); |
| @@ -58,24 +53,14 @@ | ||
| 58 | 53 | foreach ( $aawp_amazon_ids as $amazon_id ) { |
| 59 | 54 | $url_detail = $lasso_db->get_url_details_by_product_id( $amazon_id, Amazon_Api::PRODUCT_TYPE ); |
| 60 | 55 | if ( $url_detail ) { |
| 61 | 56 | $import_id = $url_detail->lasso_id; |
| 62 | - wp_update_post( | |
| 63 | - array( | |
| 64 | - 'ID' => $import_id, | |
| 65 | - 'post_status' => 'trash', | |
| 66 | - ) | |
| 67 | - ); | |
| 57 | + wp_delete_post( $import_id ); | |
| 68 | 58 | $status = $lasso_db->process_revert( $import_id, false ); |
| 69 | 59 | } |
| 70 | 60 | } |
| 71 | 61 | } elseif ( isset( $import_source ) && in_array( $import_source, array( 'AAWP', 'AmaLinks Pro', 'EasyAzon' ), true ) ) { |
| 72 | - wp_update_post( | |
| 73 | - array( | |
| 74 | - 'ID' => $import_id, | |
| 75 | - 'post_status' => 'trash', | |
| 76 | - ) | |
| 77 | - ); | |
| 62 | + wp_delete_post( $import_id ); | |
| 78 | 63 | $status = $lasso_db->process_revert( $import_id, false ); |
| 79 | 64 | } else { |
| 80 | 65 | $status = $lasso_db->process_revert( $import_id ); |
| 81 | 66 | delete_post_meta( $import_id, 'affiliate_link_type' ); |
| @@ -80,8 +65,10 @@ | ||
| 80 | 65 | $status = $lasso_db->process_revert( $import_id ); |
| 81 | 66 | delete_post_meta( $import_id, 'affiliate_link_type' ); |
| 82 | 67 | } |
| 83 | 68 | |
| 69 | + $lasso_db->delete_url_details( $import_id ); | |
| 70 | + | |
| 84 | 71 | // ? clear cache after reverting |
| 85 | 72 | Lasso_Cache_Per_Process::get_instance()->un_set( self::OBJECT_KEY . '_' . $import_id ); |
| 86 | 73 | Lasso_Cache_Per_Process::get_instance()->un_set( 'wp_post_' . $import_id ); |
| 87 | 74 | |
| @@ -579,9 +566,9 @@ | ||
| 579 | 566 | 'price' => $product['attributes']['ListPrice'] ?? $product['lowest_price_n'] ?? '', |
| 580 | 567 | 'default_url' => $product['url'], |
| 581 | 568 | 'url' => $product['url'], |
| 582 | 569 | 'image' => $product['images'][4]['url'] ?? $product['images'][ count( $product['images'] ) - 1 ]['url'], |
| 583 | - 'quantity' => 200, // Deferred: BLS quantity for out-of-stock checks (product decision — see epic #496). | |
| 570 | + 'quantity' => 200, // Manual checks won't show out of stock for now. TODO: Add BLS to out of stock checks. | |
| 584 | 571 | 'is_manual' => 1, |
| 585 | 572 | ); |
| 586 | 573 | $lasso_amazon_api->update_amazon_product_in_db( $store_data ); |
| 587 | 574 | } |