Post by 3dwebdesign » Wed May 26, 2021 5:12 pm

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.

Newbie

Posts

Joined
Fri Sep 04, 2020 7:07 pm


Post by 3dwebdesign » Wed May 26, 2021 5:24 pm

Coupons are stored in:

Code: Select all

$this->session->data['coupon']
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 ?

Newbie

Posts

Joined
Fri Sep 04, 2020 7:07 pm


Post by AndreaH » Thu Jul 08, 2021 3:30 am

Were you able to solve the problem? The solution would also interest me. Thanks in advance!

Newbie

Posts

Joined
Thu Jul 08, 2021 3:18 am

Post by 3dwebdesign » Wed Feb 23, 2022 4:42 pm

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
}

Newbie

Posts

Joined
Fri Sep 04, 2020 7:07 pm


Post by thekrotek » Wed Feb 23, 2022 5:18 pm

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'])) {

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am

Who is online

Users browsing this forum: No registered users and 33 guests