在(catalog/view/theme/*/template/common/success.tpl). 2中,我只在“OpenCart”/“谢谢”页面OpenCart中编辑标题的外观/php
因此,在catalog/view/theme/*/template/common/header.tpl中,我想要做的事情如下:
if( $is_thank_you_page ){
echo "stuff";
// bonus: I wanted to get the order email but maybe it should be a different post
}但是,如果是“成功”/“谢谢”页面,我如何才能签入header.tpl呢?
在打印页眉之前,我尝试在success.tpl中设置一个变量,但没有结果。
发布于 2020-08-31 15:46:21
您可以尝试这样的方法(根据您的URL进行操作):
<?php
$parameters = explode('/', $_SERVER['REQUEST_URI']);
if(end($parameters) === 'success.tpl'){
//the condition with $parameters depends on the exact look of your URL
//you could also access an index directly
}基本上,它接受REQUEST_URI (域后面的一部分),在/符号周围拆分它,然后检查它是否以success.tpl结尾
您还可以为end($parameters)而不是if制作一个if。
发布于 2020-08-31 16:03:11
我不知道opencart结构,但是如果这个值从未改变,您可以尝试使用strpos/stripos,比如:
if(stripos($var_with_page_title, 'thank you') !== false) {
do_something();
}发布于 2020-08-31 18:46:09
如果希望在标题中检测到签出/成功页面,请执行以下操作:
开放catalog/controller/common/header.php
发现
// Menu
$this->load->model('catalog/category');加前
// success page checking
$data['success'] = '';
if (isset($this->request->get['route']) && $this->request->get['route'] == 'checkout/success') {
$data['success'] = true;
}
// looking for email from the order
$data['success_email'] = '';
if ($this->customer->isLogged()) {
$data['success_email'] = $customer_info['email'];
} elseif (isset(this->session->data['guest']['email'])) {
$data['success_email'] = $this->session->data['guest']['email'];
}现在在catalog/view/theme/YOUR_THEME/template/common/header.tpl
添加任何你喜欢的地方
<?php if ($success) { ?>
//do something
<?php if ($success_email) { ?><?php echo $success_email; ?><?php } ?>
<?php } ?>附带奖金电子邮件
https://stackoverflow.com/questions/63673789
复制相似问题