← All changes
|
includes/Admin/Product/Services/ProductDisconnectService.php
+3
-26
1.8.8
→
1.10.21
View file →
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace SyncBasalam\Admin\Product\Services; |
| 4 | 4 | |
| 5 | -use SyncBasalam\Utilities\ProductMetaKey; | |
| 5 | +use SyncBasalam\Services\Products\ProductConnection; | |
| 6 | 6 | |
| 7 | 7 | defined('ABSPATH') || exit; |
| 8 | 8 | |
| 9 | 9 | class ProductDisconnectService |
| @@ -10,36 +10,13 @@ | ||
| 10 | 10 | { |
| 11 | 11 | public function disconnectSelected(array $productIds): void |
| 12 | 12 | { |
| 13 | 13 | foreach ($productIds as $productId) { |
| 14 | - $this->disconnectSingle($productId); | |
| 14 | + $this->disconnectSingle((int) $productId); | |
| 15 | 15 | } |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | private function disconnectSingle(int $productId): void |
| 19 | 19 | { |
| 20 | - $metaKeysToRemove = [ | |
| 21 | - ProductMetaKey::basalamProductId(), | |
| 22 | - ProductMetaKey::basalamProductSyncStatus(), | |
| 23 | - ProductMetaKey::basalamProductStatus(), | |
| 24 | - ]; | |
| 25 | - | |
| 26 | - foreach ($metaKeysToRemove as $metaKey) { | |
| 27 | - delete_post_meta($productId, $metaKey); | |
| 28 | - } | |
| 29 | - | |
| 30 | - $this->disconnectVariations($productId); | |
| 31 | - } | |
| 32 | - | |
| 33 | - private function disconnectVariations(int $productId): void | |
| 34 | - { | |
| 35 | - $product = wc_get_product($productId); | |
| 36 | - | |
| 37 | - if ($product && $product->is_type('variable')) { | |
| 38 | - $variationIds = $product->get_children(); | |
| 39 | - | |
| 40 | - foreach ($variationIds as $variationId) { | |
| 41 | - delete_post_meta($variationId, 'sync_basalam_variation_id'); | |
| 42 | - } | |
| 43 | - } | |
| 20 | + ProductConnection::purge($productId); | |
| 44 | 21 | } |
| 45 | 22 | } |