Opencart core file modifications for adding coupon support into the checkout sequence
210.1
2.5.1
Original by mhccorp.com, 1.5.2+ and 2.x versions by Qphoria
language->get('entry_payment_coupon');
$data['text_payment_coupon'] = $this->language->get('text_payment_coupon');
$data['text_payment_coupon_success'] = $this->language->get('text_payment_coupon_success');
$data['button_coupon'] = $this->language->get('button_coupon');
$data['coupon'] = isset($this->session->data['coupon']) ? $this->session->data['coupon'] : '';
if (isset($this->data)) { $this->data = array_merge($this->data, $data); } // 15x backwards compatibility
]]>
load->language('checkout/checkout');
$json = array();
$this->load->model('total/coupon');
if (isset($this->request->post['coupon'])) {
$coupon = $this->request->post['coupon'];
} else {
$coupon = '';
}
if (method_exists($this->model_total_coupon, 'getCoupon')) {
$coupon_info = $this->model_total_coupon->getCoupon($coupon);
} else {
$this->load->model('checkout/coupon');
$coupon_info = $this->model_checkout_coupon->getCoupon($coupon);
}
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_payment_coupon_success');
$json['redirect'] = $this->url->link('checkout/cart');
} else {
$json['error'] = $this->language->get('error_coupon');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
]]>
]]>
]]>