Opencart core file modifications for adding coupon + voucher support into the checkout sequence
1.5.2.x
2.1.5
mrg
data['text_comments'] = $this->language->get('text_comments');]]>
data['entry_payment_coupon'] = $this->language->get('entry_payment_coupon');
$this->data['text_payment_coupon'] = $this->language->get('text_payment_coupon');
$this->data['text_payment_coupon_success'] = $this->language->get('text_payment_coupon_success');
$this->data['button_coupon'] = $this->language->get('button_coupon');
$this->data['entry_payment_voucher'] = $this->language->get('entry_payment_voucher');
$this->data['text_payment_voucher'] = $this->language->get('text_payment_voucher');
$this->data['text_payment_voucher_success'] = $this->language->get('text_payment_voucher_success');
$this->data['button_voucher'] = $this->language->get('button_voucher');
]]>
]]>
]]>
language->load('checkout/cart');
$json = array();
if (!$this->cart->hasProducts()) {
$json['redirect'] = $this->url->link('checkout/cart');
}
if (isset($this->request->post['coupon'])) {
$this->load->model('checkout/coupon');
$coupon_info = $this->model_checkout_coupon->getCoupon($this->request->post['coupon']);
if ($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', '', 'SSL');
} else {
$json['error'] = $this->language->get('error_coupon');
}
}
$this->response->setOutput(json_encode($json));
}
public function calculate_voucher() {
$this->language->load('checkout/cart');
$json = array();
if (!$this->cart->hasProducts()) {
$json['redirect'] = $this->url->link('checkout/cart');
}
if (isset($this->request->post['voucher'])) {
$this->load->model('checkout/voucher');
$voucher_info = $this->model_checkout_voucher->getVoucher($this->request->post['voucher']);
if ($voucher_info) {
$this->session->data['voucher'] = $this->request->post['voucher'];
$this->session->data['success'] = $this->language->get('text_success');
$json['redirect'] = $this->url->link('checkout/cart', '', 'SSL');
} else {
$json['error'] = $this->language->get('error_voucher');
}
}
$this->response->setOutput(json_encode($json));
}
]]>