PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.2
ووسلام – همگام سازی ووکامرس و باسلام v1.10.2
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 / Operations / ArchiveProduct.php

ArchiveProduct.php in ووسلام – همگام سازی ووکامرس و باسلام 1.10.2, at includes/Admin/Product/Operations/ArchiveProduct.php

54 lines 1.6 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\Operations;
4
5 use SyncBasalam\Admin\Product\Operations\AbstractProductOperation;
6 use SyncBasalam\Services\Products\UpdateSingleProductService;
7
8 defined('ABSPATH') || exit;
9
10 class ArchiveProduct extends AbstractProductOperation
11 {
12 private $updateProductService;
13 private const STATUS_ARCHIVED = 3790;
14
15 public function __construct($updateProductService = null)
16 {
17 parent::__construct();
18 $this->updateProductService = $updateProductService ?: syncBasalamContainer()->get(UpdateSingleProductService::class);
19 }
20
21
22 protected function run(int $product_id, array $args = []): array
23 {
24 $result = $this->updateProductService->updateProductStatus($product_id, self::STATUS_ARCHIVED);
25
26 if (!$result) throw new \Exception('بایگانی وضعیت �
27 حصول نا�
28 وفق بود');
29
30 return [
31 'success' => true,
32 'message' => sprintf('�
33 حصول با �
34 وفقیت بایگانی شد.'),
35 'status_code' => 200,
36 'product_id' => $product_id,
37 'archived' => true
38 ];
39 }
40
41 public function validate(int $product_id): bool
42 {
43 if (!parent::validate($product_id)) return false;
44
45 $validation = $this->validator->validateBasalamConnection($product_id);
46 if (!$validation['valid']) {
47 $this->validator->logValidationResult($product_id, $validation, $this->getOperationNameFromClass());
48 return false;
49 }
50
51 return true;
52 }
53 }
54