Post by miktrwh » Tue Nov 12, 2024 7:22 am

Hello all,
I'm posting here in the hopes that you'll be able to help or at least guide me, as I've been trying to figure out the solution to this issue for two days straight, and potentially losing sales because of this.
In my online shop, I've created a coupon that makes everything 25% off, and offers free shipping. It has no usage limit, and customers may use it as many times as they want. Its start date is in the past, and the end date in the future.
When a customer applies the coupon, a success message in the cart says the coupon was applied. However, right from the bat, the price doesn't change, and the shipping fees are not waived. If they decide to go to the checkout page, the coupon is not applied there either, which makes them end up paying both the full price and the shipping fees.
I had no choice but to dive into the code. I can confirm that the session data does contain the applied coupon, the coupon exists, and it has the right settings. The coupon can be found with

Code: Select all

$this->session->data['coupon']
when inside controller pages.
It doesn't seem like the coupon class' method

Code: Select all

ModelExtensionTotalCoupon::getTotal()
gets called anywhere, except fort the

Code: Select all

ControllerApiCoupon::index()
method, which simply checks whether a coupon exists, and does not update the products' prices and / or shipping fees. The coupon information can be gathered from within the

Code: Select all

ControllerCheckoutShippingMethod
class' methods, but there doesn't seem to be a way to update the prices there either.
I've looked far and wide in the code, your forums, and Google, and yet it seems like no one else has this issue.

My shop is using Opencart 3.0.3.9. Updating now to version 4 is definitely not a choice due to incompatibilties with some of the extensions.

Thank you all in advance for your help!

Newbie

Posts

Joined
Tue Nov 12, 2024 7:11 am

Post by ADD Creative » Tue Nov 12, 2024 5:31 pm

The coupon total getTotal is call like the following in a few places.
https://github.com/opencart/opencart/bl ... t.php#L194

So make sure your coupon total in enabled in Extensions -> Extensions -> Order Totals.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by paulfeakins » Tue Nov 12, 2024 8:44 pm

miktrwh wrote:
Tue Nov 12, 2024 7:22 am
My shop is using Opencart 3.0.3.9. Updating now to version 4 is definitely not a choice due to incompatibilties with some of the extensions.
You could use 3.0.4.0?

And do you have many extensions installed? Any that might break this?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by miktrwh » Sun Nov 17, 2024 12:43 am

ADD Creative wrote:
Tue Nov 12, 2024 5:31 pm
The coupon total getTotal is call like the following in a few places.
https://github.com/opencart/opencart/bl ... t.php#L194

So make sure your coupon total in enabled in Extensions -> Extensions -> Order Totals.
Thanks for the link. I do have the same code on my end, so I looked into it and debugged it. I did make sure the extension was enabled before doing it. Indeed, I could see that the

Code: Select all

foreach ($results as $result)
was correctly querying the coupons extension to get the total amount of money for the order. However, I noticed that it was always being the first extension being queried. Since the

Code: Select all

$total_data
was being updated with the sub-total only after querying the "Sub-Total" extension, which happened after the coupons extension, I looked at the shop's "Order Totals" extension list, and then I found that the coupons extension didn't have a sort order, on which the "cart.php" page seemed to rely on to calculate the total amount due. I have no idea how it got reset, especially since the other extensions seem to have a correct sort order, but after setting the coupon's extension order to something higher than the sub-total's extension sort order, the coupons were finally being applied to the total. Thank you so much for your help ;D

Newbie

Posts

Joined
Tue Nov 12, 2024 7:11 am

Post by miktrwh » Sun Nov 17, 2024 12:45 am

paulfeakins wrote:
Tue Nov 12, 2024 8:44 pm
miktrwh wrote:
Tue Nov 12, 2024 7:22 am
My shop is using Opencart 3.0.3.9. Updating now to version 4 is definitely not a choice due to incompatibilties with some of the extensions.
You could use 3.0.4.0?

And do you have many extensions installed? Any that might break this?
If I was still unable to find the problem source, I would've tried to update it. Thankfully, I didn't need to :) About the extensions, I didn't have any extensions that would've broken the order total. However, I am absolutely not sure how the sort order for the coupons extension was reset. Thanks anyways!

Newbie

Posts

Joined
Tue Nov 12, 2024 7:11 am
Who is online

Users browsing this forum: No registered users and 23 guests