| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Actions\Controller\ProductActions; |
| 4 |
|
| 5 |
use SyncBasalam\Services\Products\GetCategoryAttr; |
| 6 |
use SyncBasalam\Actions\Controller\ActionController; |
| 7 |
|
| 8 |
defined('ABSPATH') || exit; |
| 9 |
|
| 10 |
class GetCategoryAttributes extends ActionController |
| 11 |
{ |
| 12 |
public function __invoke() |
| 13 |
{ |
| 14 |
if (isset($_POST['catID'])) { |
| 15 |
$catId = sanitize_text_field(wp_unslash($_POST['catID'])); |
| 16 |
} else { |
| 17 |
return false; |
| 18 |
} |
| 19 |
|
| 20 |
$categoryAttrs = GetCategoryAttr::getAttr($catId); |
| 21 |
|
| 22 |
if ($categoryAttrs['body']) { |
| 23 |
wp_send_json_success(['attributes' => $categoryAttrs['body']]); |
| 24 |
} else { |
| 25 |
wp_send_json_success([ |
| 26 |
[ |
| 27 |
'attributes' => [], |
| 28 |
], |
| 29 |
]); |
| 30 |
} |
| 31 |
} |
| 32 |
} |
| 33 |
|