Ekdant-Online-Store/catalog/controller/account/custom_field.php

37 lines
1.0 KiB
PHP
Raw Normal View History

2024-08-06 12:21:00 +00:00
<?php
namespace Opencart\Catalog\Controller\Account;
/**
* Class Custom Field
*
* @package Opencart\Catalog\Controller\Account
*/
class CustomField extends \Opencart\System\Engine\Controller {
/**
* @return void
*/
public function index(): void {
$json = [];
// Customer Group
if (isset($this->request->get['customer_group_id']) && in_array((int)$this->request->get['customer_group_id'], (array)$this->config->get('config_customer_group_display'))) {
$customer_group_id = (int)$this->request->get['customer_group_id'];
} else {
$customer_group_id = (int)$this->config->get('config_customer_group_id');
}
$this->load->model('account/custom_field');
$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);
foreach ($custom_fields as $custom_field) {
$json[] = [
'custom_field_id' => $custom_field['custom_field_id'],
'required' => $custom_field['required']
];
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}