【问题标题】:open cart language and currency打开购物车语言和货币
【发布时间】:2012-03-05 07:15:09
【问题描述】:

谁能回答我如何将货币与开放购物车中的语言联系起来?我的意思是

如果我更改语言,与该国家/地区相关的货币也会更改。我找遍了所有地方,但我没有找到。有没有人有这样的经历?

谢谢。

【问题讨论】:

  • 您是否要在前端将两者结合起来?例如客户只需选择国家,它就会自动选择货币?
  • 你说得对。
  • 什么版本的 OpenCart?您基本上需要编辑控制器以同时更改两者...如果您只处理几种货币,您可以对这些货币对进行硬编码。如果没有,您还需要创建一个语言到货币的复合表... 告诉我什么版本的 OC,以及您使用多少种语言
  • 打开的购物车版本是 1.5.1,站点 url 是 inksupplydepot.com/xmasdeco/ 正在测试中。有五种语言。

标签: php module currency opencart


【解决方案1】:

需要修改controller/common/header.php

if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['language_code'])) {
        $this->session->data['language'] = $this->request->post['language_code'];

        if (isset($this->request->post['redirect'])) {
            $this->redirect($this->request->post['redirect']);
        } else {
            $this->redirect($this->url->link('common/home'));
        }
    }

类似的事情:

    if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['language_code'])) {
     $this->session->data['language'] = $this->request->post['language_code'];
     $this->currency->set($this->request->post['currency_code']); 
     unset($this->session->data['shipping_methods']); 
     unset($this->session->data['shipping_method']); 
     if (isset($this->request->post['redirect'])) {
        $this->redirect($this->request->post['redirect']);
     } else {
        $this->redirect($this->url->link('common/home'));
     }
   }

我知道答案在 StackOverflow 中,但我没有再找到它。

现在..你需要修改模板 header.tpl :

   <form name="language" action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
     <div id="language">
        <img src="image/flags/se.png" alt="Svenska" title="Svenska" onclick="$('input[name=\'language_code\']').attr('value', 'se'); $('input[name=\'currency_code\']').attr('value', 'SEK'); $(this).parent().parent().submit();" />
        <img src="image/flags/dk.png" alt="Danish" title="Danish" onclick="$('input[name=\'language_code\']').attr('value', 'da').submit(); $(this).parent().parent().submit();" />
        <img src="image/flags/gb.png" alt="English" title="English" onclick="$('input[name=\'language_code\']').attr('value', 'en').submit(); $('input[name=\'currency_code\']').attr('value', 'GBP').submit(); $(this).parent().parent().submit();" />
        <input type="hidden" name="language_code" value="" />
        <input type="hidden" name="currency_code" value="" />
        <input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
     </div>
  </form>

最好的问候,

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-22
  • 1970-01-01
  • 2018-01-24
  • 1970-01-01
  • 2021-07-02
  • 1970-01-01
相关资源
最近更新 更多