| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | use SyncBasalam\Admin\Product\Operations\ArchiveProduct; |
| 8 | 8 | use SyncBasalam\Admin\Product\Operations\RestoreProduct; |
| 9 | 9 | use SyncBasalam\Jobs\Exceptions\RetryableException; |
| 10 | 10 | use SyncBasalam\Jobs\Exceptions\NonRetryableException; |
| 11 | -use SyncBasalam\Utilities\ProductMetaKey; | |
| 11 | +use SyncBasalam\Services\Products\ProductConnection; | |
| 12 | 12 | |
| 13 | 13 | defined('ABSPATH') || exit; |
| 14 | 14 | |
| 15 | 15 | class ProductOperations |
| @@ -87,22 +87,9 @@ | ||
| 87 | 87 | public static function disconnectProduct($product_id) |
| 88 | 88 | { |
| 89 | 89 | do_action('sync_basalam_before_disconnect_product', $product_id); |
| 90 | 90 | |
| 91 | - $metaKeysToRemove = ProductMetaKey::basalamProductMetaKeys(); | |
| 92 | - | |
| 93 | - foreach ($metaKeysToRemove as $metaKey) { | |
| 94 | - delete_post_meta($product_id, $metaKey); | |
| 95 | - } | |
| 96 | - | |
| 97 | - $product = wc_get_product($product_id); | |
| 98 | - | |
| 99 | - if ($product && $product->is_type('variable')) { | |
| 100 | - $variationIds = $product->get_children(); | |
| 101 | - foreach ($variationIds as $variationId) { | |
| 102 | - delete_post_meta($variationId, 'sync_basalam_variation_id'); | |
| 103 | - } | |
| 104 | - } | |
| 91 | + ProductConnection::purge($product_id); | |
| 105 | 92 | |
| 106 | 93 | $result = [ |
| 107 | 94 | 'success' => true, |
| 108 | 95 | 'message' => 'اتصال محصولات با موفقیت حذف شد.', |