Funny math in checkout cart

  • Posts: 2143
  • Thank you received: 747
9 years 2 months ago #213858

-- url of the page with the problem -- : local
-- HikaShop version -- : 2.5.0 Starter
-- Joomla version -- : 3.4.3
-- PHP version -- : 5.5.3

Hi there,

This is about free products (subscriptions) to which shipping can get added in certain zones because physical goods are getting mailed out.
Client = shop owner must be able to make exceptions and grant free shipping to select subscribers even in those zones.

I'm thinking "coupons", client likes the idea, and so I begin research.
I understand (and appreciate) that coupons apply to products only , not shipping.
Then I'm learning that in our case of fixed shipping rates, a coupon of the same fixed value can offset the shipping cost , of course. Perfect!

So, shipping = 20, coupon = 20, should result in 0, right?

Well, not quite. This is what the checkout cart looks like:



I'm having difficulties explaining this. Can you? :whistle:

Thanks a ton in advance!

EDIT:
BTW, after clicking "Finish" in checkout, this is what the "bottom line" part of the order then looks like in the backend:



Coupon code = yes, Coupon value (-20) = no, math correct, but a value got lost, so the result is still wrong... :(

Since you might ask for it: coupon config here attached.

P.S.: If the solution - for some strange reason - comes with a commercial edition: fine, the client will pretty surely end up with one anyway, ha. Just kidding... obviously, even for Starters the above behaviour and math is odd......


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
Attachments:
Last edit: 9 years 2 months ago by lousyfool.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
9 years 2 months ago #213883

Hello,
It seems like the coupon isn't applied on the shipping price, can you :
- Set a different value through the "Apply discounts" option via "Hikashop->System->Configuration->Main"
- Check that you don't have the "Coupon percentage applies to product only" option set to YES through your coupon configuration page.
and test it again ?
Thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
9 years 2 months ago #213953

Thanks Mohamed,

But...

Mohamed Thelji wrote: It seems like the coupon isn't applied on the shipping price ...

Again, I understand that coupons are not applied to shipping, but only to products - so I wonder what you mean, or have the rules changed in the past 6 weeks since Nicolas's post I linked to?

Anyway...

Mohamed Thelji wrote: - Set a different value through the "Apply discounts" option via "Hikashop->System->Configuration->Main"

It was set to "Before taxes" initially, now I changed it to "After taxes", and nothing changed, the cart screenshot would look the very same. Well, there are no taxes involved, anyway.

Then...

Mohamed Thelji wrote: - Check that you don't have the "Coupon percentage applies to product only" option set to YES through your coupon configuration page.

I don't understand... I had said I'm using the Starter edition, so I do not have this or other restrictions, of course. Also, I am using a fixed rate discount coupon and not a percentage, as well described in words and screenshot.

Sorry, but I really don't understand what you are trying to test, especially with all - more relevant? - information already provided.

Also, please compare screenshots of checkout cart and backend order. I thought the difference is pretty obvious and should send you into the right direction.

It would also be very simple for you to reproduce: Free product, fixed manual shipping rate, fixed coupon value of the same amount as shipping, off to checkout and there you go.

I guess we know as much or little as before, only I'll need to wait another 12 hours as per average......... :(

Sorry, but I'm really a bit disappointed.


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 2 months ago #213975

Hi,

As you said coupons only apply to products.
If the sum of the product prices + coupon is below 0, the total is brought back to 0 before the shipping is calculated and added to it.
In your case, I would say that there is a simple solution:
use the min/max price restrictions of your shipping methods so that if the price of the products is below 0.01, you only offer a free shipping method, otherwise, you propose the normal shipping methods.

Otherwise, you could also use AWOCoupon. That extension integrates with HikaShop for couponing and handle coupons on the shipping fee.

The following user(s) said Thank You: lousyfool

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
9 years 2 months ago #213999

Thank you, Nicolas,

Maybe I didn't make my case clear enough in my first post when I said, "... shipping can get added in certain zones ...". So, shipping does not depend on the product price at all but only on zones, and I can't see how then the min/max restrictions could help solving the case and get the coupon math right.

Just for clarification and consideration:
- Product price is always 0 = free.
- Shipping method selection depends on zone the customer is in. So, there are at least two zones, to each of which one shipping method is restricted, one of them is price = 0, the other is price = 20.

I guess the culprit in my case is described in your line

If the sum of the product prices + coupon is below 0, the total is brought back to 0 before the shipping is calculated and added to it.


But how do you explain what's happening in the backend? I had posted the screenshot already, but here it is again, showing that the coupon value gets somehow "lost"... it's set to 0.00 there:



There seems to be more happening in the system than only the total being brought back to 0 as you say, because only this wouldn't erase the coupon value, or?

Update:
Upon further investigation, I see that for an order entered in the frontend with conditions set as above, in the database the field order_discount_code does contain the coupon name, but the field order_discount_price is 0.00000, strangely. That can't be right, no matter what you said about the condition of "the total brought back to 0"?!

Additionally, if I enter a new order in the backend with same conditions (product price = 0, shipping method/price = 20) and apply a coupon there (it doesn't recognize existing coupons, but I can enter "20" as value), it all goes well, and the math is right, means the total is 0.
And then it's also all saved properly in #__hikashop_order.

This "strange behaviour" with coupon value being saved as 0 when entered in the frontend, plus the math working in the backend, makes me wonder if there is something, or something else, going "wrong" in the system, not depending on the condition to bring the total of product and coupon back to 0.

BTW, I've seen AWOCoupon, but frankly, I find US-$60 a bit steep (to put it mildly) to only get this simple math straight. Aside from that, it would still leave the mystery of the HikaShop coupon value in the database and backend = 0.00, I guess.


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
Attachments:
Last edit: 9 years 2 months ago by lousyfool. Reason: see "Update"

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 2 months ago #214005

Hi,

It's normal that the coupon value is 0 in the order. The coupon value in the order is the real value that was calculated and used.

Being able to set what you want in the order in the backend is something different than the rules that apply automatically on the frontend. For example, you can easily add a product with a price of 1, a tax amount of 2 and a tax rate of 20% in an order in the backend. It's obviously wrong, but the system will let you do it. That's because the rules which apply on the frontend so that the system behaves properly are not applied in the backend so that it lets you do as much as possible corrections in orders in order to deal with special cases when the customer calls you for whatever reason and that you have to rectify whatever is needed.

I don't feel that the price of AWOCoupon is expensive. If you look around for extensions for other carts, you'll be able to see much higher prices for a lot less functions. But yes, compared to the small price we ask for HikaShop, it can seem high.
Now if you prefer to change the math in HikaShop to suits your needs, it's possible. You want to edit the file administrator/components/com_hikashop/classes/cart.php and modify the loadFullCart function so that the coupon is loaded after the shipping and that should take care of it.

The following user(s) said Thank You: lousyfool

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
9 years 2 months ago #214038

Thank you once again, Nicolas!

This explains things sufficiently, indeed. Admittedly, I haven't been that deeply into the coupon feature, and where I used it, there wasn't any reason to question anything.
Same with the backend order entry - this all came up for me at this detail only now.

So, I apologise if I stirred up any dust unnecessarily.

Oh, and yes, I'll see that I get the coupon working as it seems to be best for this project, as coupons will never be used any other way here. So, thanks for the hint on the classes file as well.

Finally, AWOCoupon does a lot of good things according to its feature list and might come handy in some other job, maybe. No problem with paying for a problem solver or efficient time saver, but here it's just one tiny "issue". And this cart will not even provide the client with an active income as in regular cases, instead it will only solve a problem. Yeah sure, maybe save the client a few bucks in the long run. Part of the small budget I'll then rather steer towards getting you a new licensee! :)


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
9 years 2 months ago #214043

nicolas wrote: You want to edit the file administrator/components/com_hikashop/classes/cart.php and modify the loadFullCart function so that the coupon is loaded after the shipping and that should take care of it.


It does take care of it! Works great - many thanks again! :)


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

Please Log in or Create an account to join the conversation.

Time to create page: 0.104 seconds
Powered by Kunena Forum