【问题标题】:Restrict coupon code buy chosen currency in OpenCart限制优惠券代码在 OpenCart 中购买所选货币
【发布时间】:2016-11-02 20:59:45
【问题描述】:

是否可以通过 OpenCart 中选择的货币来限制优惠券代码?

例如 店里有两种货币XX和YY。如果买家选择 XX 货币,优惠券代码字段在购物车中可见。在其他情况下(选择货币 YY)不是。

OpenCart 2.0.3.1

【问题讨论】:

  • 到目前为止,您做了哪些无效的操作?

标签: opencart coupon


【解决方案1】:

是的,打开这个文件: catalog/controller/checkout/coupon.php 在 2.0.3.1 版本中

找到:

    if (empty($this->request->post['coupon'])) {
        $json['error'] = $this->language->get('error_empty');

        unset($this->session->data['coupon']);
    } elseif ($coupon_info) {
        $this->session->data['coupon'] = $this->request->post['coupon'];

        $this->session->data['success'] = $this->language->get('text_success');

        $json['redirect'] = $this->url->link('checkout/cart');
    } else {
        $json['error'] = $this->language->get('error_coupon');
    }

改成:

    if (empty($this->request->post['coupon'])) {
        $json['error'] = $this->language->get('error_empty');

        unset($this->session->data['coupon']);
    } elseif ($coupon_info) {
        // here I use USD for example
        if($this->session->data['currency'] == 'USD'){
            $this->session->data['coupon'] = $this->request->post['coupon'];

            $this->session->data['success'] = $this->language->get('text_success');

            $json['redirect'] = $this->url->link('checkout/cart');
        } else {
            // Write your custom error message here
            $json['error'] = 'This coupon is only available in USD';

            unset($this->session->data['coupon']);
        }
    } else {
        $json['error'] = $this->language->get('error_coupon');
    }

【讨论】:

    猜你喜欢
    • 2018-05-17
    • 2018-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    • 1970-01-01
    • 2021-07-20
    相关资源
    最近更新 更多