PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.8.6
ووسلام – همگام سازی ووکامرس و باسلام v1.8.6
1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 All 53 releases
sync-basalam / includes / Admin / Product / Services / ProductDisconnectService.php

ProductDisconnectService.php in ووسلام – همگام سازی ووکامرس و باسلام 1.8.6, at includes/Admin/Product/Services/ProductDisconnectService.php

46 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SyncBasalam\Admin\Product\Services;
4
5 use SyncBasalam\Utilities\ProductMetaKey;
6
7 defined('ABSPATH') || exit;
8
9 class ProductDisconnectService
10 {
11 public function disconnectSelected(array $productIds): void
12 {
13 foreach ($productIds as $productId) {
14 $this->disconnectSingle($productId);
15 }
16 }
17
18 private function disconnectSingle(int $productId): void
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 }
44 }
45 }
46