| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Actions\Controller\ProductActions; |
| 4 |
|
| 5 |
use SyncBasalam\Admin\Product\ProductOperations; |
| 6 |
use SyncBasalam\Actions\Controller\ActionController; |
| 7 |
|
| 8 |
defined('ABSPATH') || exit; |
| 9 |
|
| 10 |
class RestoreProduct extends ActionController |
| 11 |
{ |
| 12 |
public function __invoke() |
| 13 |
{ |
| 14 |
$productOperations = syncBasalamContainer()->get(ProductOperations::class); |
| 15 |
$productId = isset($_POST['product_id']) ? sanitize_text_field(wp_unslash($_POST['product_id'])) : null; |
| 16 |
|
| 17 |
if (!$productId) { |
| 18 |
wp_send_json_error(['message' => 'آیدی � |
| 19 |
حصول الزا� |
| 20 |
ی است.'], 400); |
| 21 |
} |
| 22 |
|
| 23 |
try { |
| 24 |
$result = $productOperations->restoreExistProduct($productId); |
| 25 |
} catch (\Exception $e) { |
| 26 |
wp_send_json_error($e->getMessage(), 500); |
| 27 |
} |
| 28 |
if (!$result['success']) { |
| 29 |
wp_send_json_error(['message' => $result['message']], $result['status_code'] ?? 500); |
| 30 |
} |
| 31 |
|
| 32 |
wp_send_json_success(['message' => $result['message']], $result['status_code'] ?? 200); |
| 33 |
} |
| 34 |
} |
| 35 |
|