【问题标题】:php page refresh once - opencartphp页面刷新一次-opencart
【发布时间】:2014-11-18 21:40:24
【问题描述】:

我的 opencart 网站有问题。我一直希望设置送货地址非马来西亚的客户始终以美元付款。

问题是他们会选择 MYR 并选择非马来西亚国家和支付。

所以我在 catalog/controller/checkout/checkout.php 应用了以下内容

     $this->currency->set('MYR'); 
     if ($_SESSION['shipping_zone_id'] == '3528'){ 
     $this->currency->set('USD');
     }

问题是货币进入会话,它需要刷新页面,所以我应用了以下内容:

     $this->currency->set('MYR'); 
     if ($_SESSION['shipping_zone_id'] == '3528'){ 
     $this->currency->set('USD');
     $sec = "10";
     header("Refresh: $sec; url=index.php?route=checkout/checkout");
     }

上面是刷新页面,但它不断刷新页面。我希望它只刷新一次。 请指教

【问题讨论】:

  • header() 之前显示var_dump($_SESSION['shipping_zone_id']);
  • 注意到当我应用 var_dump($_SESSION['shipping_zone_id']);
  • 我希望您已经注释/删除了标题行并用die()exit 函数替换它?
  • 这是我使用的 $this->currency->set('MYR'); if ($_SESSION['shipping_zone_id'] == '3528'){ $this->currency->set('USD'); $sec = "1"; var_dump($_SESSION['shipping_zone_id']); exit (header("Refresh: $sec; url=index.php?route=checkout/checkout")); }
  • 不要向exit 添加任何内容。完全删除refresh

标签: php opencart


【解决方案1】:

在下面添加代码行

$this->currency->set('MYR'); 
 if ($_SESSION['shipping_zone_id'] == '3528'){ 
 $this->currency->set('USD');


 if(!empty($_GET['refresh']) && $_GET['refresh'] == 0 ){} //add this
else{

 $sec = "10";
 header("Refresh: $sec; url=index.php?refresh=0&route=checkout/checkout");

 } //and close it here

 }

【讨论】:

    猜你喜欢
    • 2021-05-03
    • 1970-01-01
    • 1970-01-01
    • 2011-10-22
    • 2018-12-20
    • 1970-01-01
    • 2020-02-09
    • 2013-07-08
    • 2012-02-08
    相关资源
    最近更新 更多