У версії модуля Simple 4.7.9, а ймовірно, і в багатьох інших, присутня проблема з екрануванням символів. Якщо у вас встановлено доповнення для доставки, наприклад: NovaPoshta (Нова Пошта), Justin, Meest, і в налаштуваннях Simple для поля Місто або Адреса використовується плагін Select2, тоді виникає проблема з вибором усіх варіантів, у назві яких є апостроф. Наприклад: Кам’янчани. Одразу після вибору такого варіанта виконується AJAX-запит на оновлення форми замовлення, і обране значення скидається — тобто зникає.
Редагуємо модифікатор “Shipping Data for Simple checkout and registration” в адмінці сайту
<file path="catalog/model/tool/simpleapimain.php|catalog/model/tool/simpleapicustom.php">
<operation>
<search><![CDATA[extends Model {]]></search>
<add position="after"><![CDATA[
/* START Shipping data */
public function getShippingCities($zone_id) {
$this->load->model('extension/module/shippingdata');
$shipping_method = $this->model_extension_module_shippingdata->getShippingMethod();
$values = array(
array(
'id' => '',
'text' => $this->language->get('text_select')
)
);
if ($shipping_method['method'] == 'justin') {
$results = $this->model_extension_module_shippingdata->getJustinCities($zone_id);
if (!$results) {
$values[] = array(
'id' => 0,
'text' => $this->language->get('text_none')
);
} else {
foreach ($results as $result) {
$values[] = array(
'id' => trim($result['description']),
'text' => trim($result['description'])
);
}
}
} elseif ($shipping_method['method'] == 'ukrposhta') {
$results = $this->model_extension_module_shippingdata->getUkrPoshtaCities($zone_id);
if (!$results) {
$values[] = array(
'id' => 0,
'text' => $this->language->get('text_none')
);
} else {
foreach ($results as $result) {
$values[] = array(
'id' => trim($result['description']),
'text' => trim($result['description'])
);
}
}
} elseif ($shipping_method['method'] == 'rozetka_delivery') {
$results = $this->model_extension_module_shippingdata->getRozetkaDeliveryCities();
if (!$results) {
$values[] = array(
'id' => 0,
'text' => $this->language->get('text_none')
);
} else {
foreach ($results as $result) {
$values[] = array(
'id' => trim($result['description']),
'text' => trim($result['description'])
);
}
}
} else {
$results = $this->model_extension_module_shippingdata->getNovaPoshtaCities($zone_id);
if (!$results) {
$values[] = array(
'id' => 0,
'text' => $this->language->get('text_none')
);
} else {
foreach ($results as $result) {
$values[] = array(
'id' => trim(htmlspecialchars($result['description'], ENT_QUOTES, 'UTF-8')),
'text' => trim($result['description'])
);
}
}
}
return $values;
}
public function getShippingDepartments($city_name) {
$this->load->model('extension/module/shippingdata');
$city_name = html_entity_decode($city_name, ENT_QUOTES, 'UTF-8');
$shipping_mthod = $this->model_extension_module_shippingdata->getShippingMethod();
$values = array(
array(
'id' => '',
'text' => $this->language->get('text_select')
)
);
if ($shipping_method['method'] == 'justin') {
$results = $this->model_extension_module_shippingdata->getJustinDepartments($city_name);
if (!$results) {
$values[] = array(
'id' => 0,
'text' => $this->language->get('text_none')
);
} else {
foreach ($results as $result) {
$values[] = array(
'id' => trim($result['description']),
'text' => trim($result['description'])
);
}
}
} elseif ($shipping_method['method'] == 'ukrposhta') {
$results = $this->model_extension_module_shippingdata->getUkrPoshtaDepartments($city_name, '', $shipping_method['sub_method']);
if (!$results) {
$values[] = array(
'id' => 0,
'text' => $this->language->get('text_none')
);
} else {
foreach ($results as $result) {
$values[] = array(
'id' => trim($result['description']),
'text' => trim($result['description'])
);
}
}
} elseif ($shipping_method['method'] == 'rozetka_delivery') {
$results = $this->model_extension_module_shippingdata->getRozetkaDeliveryDepartments($city_name);
if (!$results) {
$values[] = array(
'id' => 0,
'text' => $this->language->get('text_none')
);
} else {
foreach ($results as $result) {
$values[] = array(
'id' => trim($result['description']),
'text' => trim($result['description'])
);
}
}
} else {
$results = $this->model_extension_module_shippingdata->getNovaPoshtaDepartments($city_name);
if (!$results) {
$values[] = array(
'id' => 0,
'text' => $this->language->get('text_none')
);
} else {
foreach ($results as $result) {
$values[] = array(
'id' => trim(htmlspecialchars($result['description'], ENT_QUOTES, 'UTF-8')),
'text' => trim($result['description'])
);
}
}
}
return $values;
}
public function getShippingPoshtomats($city_name) {
$this->load->model('extension/module/shippingdata');
$city_name = html_entity_decode($city_name, ENT_QUOTES, 'UTF-8');
$values = array(
array(
'id' => '',
'text' => $this->language->get('text_select')
)
);
$results = $this->model_extension_module_shippingdata->getNovaPoshtaPoshtomats($city_name);
if (!$results) {
$values[] = array(
'id' => 0,
'text' => $this->language->get('text_none')
);
} else {
foreach ($results as $result) {
$values[] = array(
'id' => trim(htmlspecialchars($result['description'], ENT_QUOTES, 'UTF-8')),
'text' => trim($result['description'])
);
}
}
return $values;
}
/* END Shipping data */
]]></add>
</operation>
</file>
І останнім залишається модель модуля доставки
// знаходимо метод
// public function getNovaPoshtaCities($region, $search = '') {
// коментуємо це return $this->db->query($sql)->rows; та додаємо після
$results = $this->db->query($sql)->rows;
$data = array();
foreach ($results as $result) {
$data[] = array(
'description' => htmlspecialchars($result['description'], ENT_QUOTES, 'UTF-8'),
);
}
// знаходимо метод та додаємо після
// public function getNovaPoshtaDepartments($city, $search = '') {
$city = html_entity_decode($city, ENT_QUOTES, 'UTF-8');
// знаходимо метод та додаємо після
// public function getNovaPoshtaPoshtomats($city, $search = '') {
$city = html_entity_decode($city, ENT_QUOTES, 'UTF-8');