Page 1 of 1
Accept order in Opencart 2.3 only if coupon code is used
Posted: Wed May 26, 2021 5:12 pm
by 3dwebdesign
Hello. I'm trying to modify Opencart 2.3 without success to get the following: When on cart page is used valid coupon code, go to checkout page and execute standard Opencart checkout process. If not used valid coupon, stay on the cart page - execute something like this:
Code: Select all
$this->response->redirect($this->url->link('checkout/cart'));
I tried to do some check in catalog/controller/checkout/checkout.php and catalog/controller/extension/total/coupon.php without success. Like:
Code: Select all
if ($data['coupon'] == '') {
$this->response->redirect($this->url->link('checkout/cart'));
}
else {
}
Please, help me if you know how it can be done.
Re: Accept order in Opencart 2.3 only if coupon code is used
Posted: Wed May 26, 2021 5:24 pm
by 3dwebdesign
Coupons are stored in:
But the check is valid coupon code or not, is $data['coupon'] I think. So, the question is may be how to get $data['coupon'] in catalog/controller/checkout/checkout.php ?
Re: Accept order in Opencart 2.3 only if coupon code is used
Posted: Thu Jul 08, 2021 3:30 am
by AndreaH
Were you able to solve the problem? The solution would also interest me. Thanks in advance!
Re: Accept order in Opencart 2.3 only if coupon code is used
Posted: Wed Feb 23, 2022 4:42 pm
by 3dwebdesign
Yes, solved. Add in catalog/controller/checkout/checkout.php before: // Validate minimum quantity requirements
Code: Select all
if (isset($this->session->data['coupon']) == '') {
$this->response->redirect($this->url->link('checkout/cart')); // if no coupon used, redirect back to cart page
}
else {
// your code
}
Re: Accept order in Opencart 2.3 only if coupon code is used
Posted: Wed Feb 23, 2022 5:18 pm
by thekrotek
3dwebdesign wrote: ↑Wed Feb 23, 2022 4:42 pm
if (isset($this->session->data['coupon']) == '') {
What a weird coding... Should be:
if (!empty($this->session->data['coupon'])) {