PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.6
ووسلام – همگام سازی ووکامرس و باسلام v1.10.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 / Services / Orders / PostAutoConfirmOrder.php

PostAutoConfirmOrder.php in ووسلام – همگام سازی ووکامرس و باسلام 1.10.6, at includes/Services/Orders/PostAutoConfirmOrder.php

59 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\Services\Orders;
4
5 use SyncBasalam\Config\Endpoints;
6 use SyncBasalam\Services\ApiServiceManager;
7
8 defined('ABSPATH') || exit;
9 class PostAutoConfirmOrder
10 {
11 private $url;
12 private $apisevice;
13
14 public function __construct()
15 {
16 $this->url = Endpoints::ORDER_AUTO_CONFIRM_CONFIG;
17 $this->apisevice = syncBasalamContainer()->get(ApiServiceManager::class);
18 }
19
20 public function postAutoConfirmOrder($isActive = true, $key = 6392)
21 {
22 $data = [
23 [
24 "title" => "تایید خودکار ه�
25 ه سفارش ها",
26 "key" => $key,
27 "is_active" => $isActive,
28 "rules" => null,
29 ],
30 ];
31
32 try {
33 $response = $this->apisevice->put($this->url, $data);
34 } catch (\Exception $e) {
35 return [
36 'success' => false,
37 'message' => 'خطا در تنظی�
38 تایید خودکار: ' . $e->getMessage(),
39 'status_code' => 500,
40 ];
41 }
42
43 if ($response['status_code'] == 200) {
44 return [
45 'success' => true,
46 'message' => 'تایید خودکار سفارشات با �
47 وفقیت فعال شد.',
48 'status_code' => $response['status_code'] ?? 200,
49 ];
50 }
51
52 return [
53 'success' => false,
54 'message' => $response['message'] ?? 'خطایی در فعال سازی تایید خودکار سفارشات رخ داده است.',
55 'status_code' => $response['status_code'] ?? 500,
56 ];
57 }
58 }
59