限制优惠券代码在OpenCart中购买所选货币

时间:2016-06-30 16:22:41

标签: opencart coupon

是否可以在OpenCart中按所选币种限制优惠券代码?

E.g。 商店有两种货币XX和YY。如果买家选择XX货币,则在购物车中可以看到优惠券代码字段。在其他情况下(货币YY选择)不。

OpenCart 2.0.3.1

1 个答案:

答案 0 :(得分:0)

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

查找

    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');
    }