我目前正在尝试覆盖PrestaShop 1.6.1中的核心控制器保护功能。控制器是AddressController.php 覆盖控制器如下所示:
class AddressController extends AddressControllerCore
{
/**
* Assign template vars related to countries display
*/
protected function assignCountries()
{
$this->id_country = (int)Tools::getCountry($this->_address);
// Generate countries list
if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
$countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
} else {
$countries = Country::getCountries($this->context->language->id, true);
}
// @todo use helper
$list = '';
$product_by_country = Configuration::get('TOOLPRODUCTCOUNTRY_PRICE');
foreach ($countries as $country) {
if($product_by_country==1){
if (isset(Context::getContext()->cookie->productcountry_delivery)) {
$selected = ((int)$country['id_country'] === Context::getContext()->cookie->productcountry_delivery) ? ' selected="selected"' : '';
} else {
$selected = ((int)$country['id_country'] === $this->id_country) ? ' selected="selected"' : '';
}
} else {
$selected = ((int)$country['id_country'] === $this->id_country) ? ' selected="selected"' : '';
}
$list .= '<option value="'.(int)$country['id_country'].'"'.$selected.'>'.htmlentities($country['name'], ENT_COMPAT, 'UTF-8').'</option>';
}
// Assign vars
$this->context->smarty->assign(array(
'countries_list' => $list,
'countries' => $countries,
'sl_country' => (int)$this->id_country,
));
}
}
基本上我想在结帐步骤中将默认国家/地区显示为在PrestaShop BO中为$('#id_country')
下拉列表选择的另一个国家/地区。在结帐流程之前选择所需的国家/地区,并将其存储为productcountry_delivery
。
问题是Prestashop没有考虑这个代码,好像它不存在。
我从cache文件夹中删除了class_index.php以强制重新编译,但又没有成功
有人可以帮我解决这个问题吗?
谢谢!