| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Actions\Controller\OrderActions; |
| 4 |
|
| 5 |
use SyncBasalam\Actions\Controller\ActionController; |
| 6 |
use SyncBasalam\Services\Orders\DelayReqOrderService; |
| 7 |
|
| 8 |
defined('ABSPATH') || exit; |
| 9 |
|
| 10 |
class DelayOrder extends ActionController |
| 11 |
{ |
| 12 |
public function __invoke() |
| 13 |
{ |
| 14 |
$orderId = isset($_POST['order_id']) ? intval($_POST['order_id']) : 0; |
| 15 |
$description = isset($_POST['description']) ? sanitize_text_field(wp_unslash($_POST['description'])) : ''; |
| 16 |
$postponeDays = isset($_POST['postpone_days']) ? intval($_POST['postpone_days']) : 0; |
| 17 |
|
| 18 |
$orderManager = new DelayReqOrderService(); |
| 19 |
|
| 20 |
$result = $orderManager->delayReqOnBasalam($orderId, $description, $postponeDays); |
| 21 |
|
| 22 |
if (!$result['success']) { |
| 23 |
wp_send_json_error(['message' => $result['message']], $result['status_code'] ?? 500); |
| 24 |
} |
| 25 |
|
| 26 |
wp_send_json_success(['message' => $result['message']], $result['status_code'] ?? 200); |
| 27 |
} |
| 28 |
} |
| 29 |
|