Вот очень хорошая ссылка,
но она не совсем подходит для свежей осStore 1.5.4.1
http://arnit.com.ua/blog/?do=findComment&comment=15
В контроллере пришлось комментировать очень много строк чтобы убрать требование страны и региона.
Удалять пришлось не только в Validate(), но и еще в нескольких местах,
например,
$this->session->data['shipping_country_id'] = $this->request->post['country_id'];
$this->session->data['shipping_zone_id'] = $this->request->post['zone_id'];
$this->session->data['shipping_postcode'] = $this->request->post['postcode'];
Иначе, я так понимаю т.к. данных не было (мы же их скрыли в темплейте, снова выходит ошибка.
======
В итоге чтобы убрать Страну и Регион
(ну и попутно индекс)
пришлось закомментировать строки в разных местах:
/**
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && (utf8_strlen($this->request->post['postcode']) < 2) || (utf8_strlen($this->request->post['postcode']) > 10)) {
$json['error']['postcode'] = $this->language->get('error_postcode');
}
**/
/**
}
if ($this->request->post['country_id'] == '') {
$json['error']['country'] = $this->language->get('error_country');
}
if ($this->request->post['zone_id'] == '') {
$json['error']['zone'] = $this->language->get('error_zone');
}
**/
if (!$json) {
$this->session->data['guest']['customer_group_id'] = $customer_group_id;
$this->session->data['guest']['firstname'] = $this->request->post['firstname'];
$this->session->data['guest']['lastname'] = $this->request->post['lastname'];
$this->session->data['guest']['email'] = $this->request->post['email'];
$this->session->data['guest']['telephone'] = $this->request->post['telephone'];
$this->session->data['guest']['fax'] = $this->request->post['fax'];
$this->session->data['guest']['payment']['firstname'] = $this->request->post['firstname'];
$this->session->data['guest']['payment']['lastname'] = $this->request->post['lastname'];
$this->session->data['guest']['payment']['company'] = $this->request->post['company'];
$this->session->data['guest']['payment']['company_id'] = $this->request->post['company_id'];
$this->session->data['guest']['payment']['tax_id'] = $this->request->post['tax_id'];
$this->session->data['guest']['payment']['address_1'] = $this->request->post['address_1'];
$this->session->data['guest']['payment']['address_2'] = $this->request->post['address_2'];
//$this->session->data['guest']['payment']['postcode'] = $this->request->post['postcode'];
$this->session->data['guest']['payment']['city'] = $this->request->post['city'];
//$this->session->data['guest']['payment']['country_id'] = $this->request->post['country_id'];
//$this->session->data['guest']['payment']['zone_id'] = $this->request->post['zone_id'];
$this->load->model('localisation/country');
/**
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
if ($country_info) {
$this->session->data['guest']['payment']['country'] = $country_info['name'];
$this->session->data['guest']['payment']['iso_code_2'] = $country_info['iso_code_2'];
$this->session->data['guest']['payment']['iso_code_3'] = $country_info['iso_code_3'];
$this->session->data['guest']['payment']['address_format'] = $country_info['address_format'];
} else {
$this->session->data['guest']['payment']['country'] = '';
$this->session->data['guest']['payment']['iso_code_2'] = '';
$this->session->data['guest']['payment']['iso_code_3'] = '';
$this->session->data['guest']['payment']['address_format'] = '';
}
$this->load->model('localisation/zone');
$zone_info = $this->model_localisation_zone->getZone($this->request->post['zone_id']);
if ($zone_info) {
$this->session->data['guest']['payment']['zone'] = $zone_info['name'];
$this->session->data['guest']['payment']['zone_code'] = $zone_info['code'];
} else {
$this->session->data['guest']['payment']['zone'] = '';
$this->session->data['guest']['payment']['zone_code'] = '';
}
**/
if (!empty($this->request->post['shipping_address'])) {
$this->session->data['guest']['shipping_address'] = true;
} else {
$this->session->data['guest']['shipping_address'] = false;
}
// Default Payment Address
//$this->session->data['payment_country_id'] = $this->request->post['country_id'];
//$this->session->data['payment_zone_id'] = $this->request->post['zone_id'];
if ($this->session->data['guest']['shipping_address']) {
$this->session->data['guest']['shipping']['firstname'] = $this->request->post['firstname'];
$this->session->data['guest']['shipping']['lastname'] = $this->request->post['lastname'];
$this->session->data['guest']['shipping']['company'] = $this->request->post['company'];
$this->session->data['guest']['shipping']['address_1'] = $this->request->post['address_1'];
$this->session->data['guest']['shipping']['address_2'] = $this->request->post['address_2'];
//$this->session->data['guest']['shipping']['postcode'] = $this->request->post['postcode'];
$this->session->data['guest']['shipping']['city'] = $this->request->post['city'];
//$this->session->data['guest']['shipping']['country_id'] = $this->request->post['country_id'];
//$this->session->data['guest']['shipping']['zone_id'] = $this->request->post['zone_id'];
/**
if ($country_info) {
$this->session->data['guest']['shipping']['country'] = $country_info['name'];
$this->session->data['guest']['shipping']['iso_code_2'] = $country_info['iso_code_2'];
$this->session->data['guest']['shipping']['iso_code_3'] = $country_info['iso_code_3'];
$this->session->data['guest']['shipping']['address_format'] = $country_info['address_format'];
} else {
$this->session->data['guest']['shipping']['country'] = '';
$this->session->data['guest']['shipping']['iso_code_2'] = '';
$this->session->data['guest']['shipping']['iso_code_3'] = '';
$this->session->data['guest']['shipping']['address_format'] = '';
}
if ($zone_info) {
$this->session->data['guest']['shipping']['zone'] = $zone_info['name'];
$this->session->data['guest']['shipping']['zone_code'] = $zone_info['code'];
} else {
$this->session->data['guest']['shipping']['zone'] = '';
$this->session->data['guest']['shipping']['zone_code'] = '';
}
// Default Shipping Address
$this->session->data['shipping_country_id'] = $this->request->post['country_id'];
$this->session->data['shipping_zone_id'] = $this->request->post['zone_id'];
$this->session->data['shipping_postcode'] = $this->request->post['postcode'];
**/
}
$this->session->data['account'] = 'guest';
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
$this->response->setOutput(json_encode($json));
}
Всё ли правильно сделал? Просто смущает что я не только проверку (ф-ция Validate) закомментировал но и то что выше для вывода (без этого не работает, я так понимаю потому что ему пустые значения всё равно надо передать)
И второй вопрос.
Убрать компанию и Компания ID.
В настройках default группы пользователей убрал всё что связано с Company ID, но само название компании осталось. Если его просто убрать в guest.php, то возникает ошибка (опять же, ему нужно хотя бы пустое значение).
Пришлось тоже комментировать всё что связано с Company.
(Действительно ли в админке убирается только Company ID, а саму Company приходится вырезать уже вручную в коде?)
Оставляем само поле, чтобы оно передавалось с пустым значением и не выводилось пользователю...
<!--<?php echo $entry_company; ?><br />-->
<input type="text" name="company" value="<?php echo $company; ?>" class="large-field" style="display:none"/>
<!--<br />
<br />-->