我使用Opencart版本1.5.4.1,并且我已经安装了商店模块并在下拉列表中有3个商店(示例默认值,Store1,Store2(。
我的要求是将最后一个商店(示例商店 2(重定向到 account/login
.
我试图将'catalog'controller'module'store.php
中的路径从index.php?route=common/home
修改为index.php?route=account/login
,但Store1和Store2都被重定向到account/login
。
我还尝试使用以下if
条件:如果我从默认到 Store1 和 Store1 到 Store2 中进行选择,它正在工作,但如果从默认值到 Store2 中选择任何选项,它不起作用。
foreach ($results as $result) {
if((int)$this->config->get('config_store_id')==1)
{
$this->data['stores'][] = array(
'store_id' => $result['store_id'],
'name' => $result['name'],
'url' => $result['url'] . 'index.php?route=account/login'
);
}
else
{
$this->data['stores'][] = array(
'store_id' => $result['store_id'],
'name' => $result['name'],
'url' => $result['url'] . 'index.php?route=common/home'
);
}
}
您可以使用
以下vqmod code
:
- 将其复制到扩展名为
.xml
的文件。 - 将其上传到
vqmod'xml
文件夹。 - 商店 ID 设置为 1,如果您的商店编号不同,请进行更改。
<modification>
<id>Force Customer Login</id>
<version>152.1</version>
<vqmver>2.1.5</vqmver>
<author>Qphoria</author>
<file name="catalog/controller/common/header.php">
<operation>
<search position="after"><![CDATA[function index()]]></search>
<add trim="true">
<![CDATA[//Q: Force Customer Login
$match = false;
if (!empty($this - > request - > get['route'])) {
$skip = array(
'payment',
'feed',
'forgotten',
'login',
'register', );
foreach($skip as $s) {
if (strpos($this - > request - > get['route'], $s) !== false) {
$match = true;
break;
}
}
}
if (!$match) {
if (!$this - > customer - > isLogged()) {
if ($this - > config - > get('config_store_id') == 1) {
$this - > redirect($this - > url - > link('account/login', 'SSL'));
}
}
}
]]>
</add>
</operation>
</file>
</modification>