Forums / Bug Reports / Coupons, some bugs?

Coupons, some bugs?

Started by rued on 3 Nov 2010, 7:48 PM · Views: 11,116

Results 21 to 40 of 60
18 Nov 2010, 12:30 AM
#21
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Coupons, some bugs?

DrByte:

It is a config option in the module.

I think your points related to shipping calculations in this topic are symptoms and not root causes.

Where is that config option, what do you call it?

Symptoms of what, I don't follow your thinking here - please enlighten us.

18 Nov 2010, 12:37 AM
#22
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Coupons, some bugs?

DrByte:

Using 0 decimals as the common day-to-day method of doing commerce?
I've been looking around online and the various stores I've found that allow shopping in NOK seem to present 2 decimal places. And can't find any reference which states that 0 decimals is the "normal" practice there.

Or are you just trying to make your store prices "pretty" by rounding them to the nearest kr ?

You have to understand the fact that decimal values do not have the "same" value in all currencies, as in Dollar and Euro - and it makes no sense to list them. Unless the prices is extremely low on the majority of the products ...

You can walk into any store in Norway, Denmark, Sweden etc. and you will have problem finding any using decimals in their product prices.

So yes, using 0 decimals is a common day-to-day method of doing commerce in Scandinavia and other countries where decimals has low value in local currencies.

If most of the Zen Cart users etc. are using decimals, it doesn't have to be normal in the "real" world. The reason is maybe more that they don't know how to change it, or because they has discovered the problems the code causes when they are doing it. ;)

18 Nov 2010, 1:24 AM
#24
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Coupons, some bugs?

rued:

DrByte:

rued:

PS! If you believe someone ever will need to remove shipping tax from the tax total, when shipping isn't included in first place - make it a config option in the module.
It is a config option in the module.

I think your points related to shipping calculations in this topic are symptoms and not root causes.

Where is that config option, what do you call it?

Symptoms of what, I don't follow your thinking here - please enlighten us.
Admin->Modules->Order Total->ot_coupon->Edit->"Include Shipping"

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Nov 2010, 10:01 AM
#25
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Coupons, some bugs?

DrByte:

Admin->Modules->Order Total->ot_coupon->Edit->"Include Shipping"

That's something different, I don't want to include shipping - and I don't want shipping tax to be removed from total when shipping isn't included. Why would someone do that?

The discount is for product totals, not shipping. Normally the shop doesn't earn money on shipping, and can't give discounts on it.

Please explain how you are thinking about this.

Why do you want to remove shipping tax when shipping isn't included?

18 Nov 2010, 5:46 PM
#26
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Coupons, some bugs?

rued:

That's something differentNo, it's not different. That setting specifically controls whether that line of code you commented out gets executed.
You wouldn't need to comment it out if you set the switch to false.
rued:

That's something different, I don't want to include shipping - and I don't want shipping tax to be removed from total when shipping isn't included. Why would someone do that?

The discount is for product totals, not shipping. Normally the shop doesn't earn money on shipping, and can't give discounts on it.

Please explain how you are thinking about this.

Why do you want to remove shipping tax when shipping isn't included?
If you set that setting to False, then Shipping is not included. Nor is the tax on shipping adjusted.
If you DO have shipping included, then the appropriate tax adjustments would also be made.

I don't understand why you're going in circles about shipping tax if you're not doing anything with shipping at all. Turn off the shipping option in the module, and then that line of code won't be executed. It's simple.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Nov 2010, 11:59 PM
#28
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Coupons, some bugs?

I'm guessing you're trying to tell me that you've set "Include Shipping" to false?

If so, then the line which you subsequently commented out wouldn't be firing, thus not impacting you, and thus that line is unrelated to your problems.

This discussion doesn't seem to be going anywhere useful. I'm not wanting to be argumentative.

I've already told you that we're investigating potential ways to address the rounding problem encountered when changing your store to 0 decimal places and using coupon-minimum-value restrictions.

As to your assertions about problems with shipping, I'm still not following why you think something should be changed there. The module already has an option to disable calculations related to shipping if you wish, and the code which adjusts shipping and shipping tax only fires if that option has been set to true. So, I'm having trouble understanding why you think there's a problem there.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Nov 2010, 1:07 AM
#29
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Coupons, some bugs?

Did you ever test this http://www.zen-cart.com/forum/showpost.php?p=957731&postcount=16 ? :huh:

Now also test by adding a new product with the price 1000 incl. tax, and see it also failing in tests because of error in tax handling for the shipping modules in coupons.

23 Nov 2010, 2:06 AM
#30
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Coupons, some bugs?

In that scenario, with a 1000 product, and flat-rate shipping, and setting the ot_coupon module's "Include Shipping" option to false it rejects the 1000 coupon. With the "Include Shipping" option to true, it accepts the coupon.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

23 Nov 2010, 2:07 AM
#31
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Coupons, some bugs?

Try this:
Edit /includes/modules/order_total/ot_coupon.php
Line 476 says this:$order_total = array('totalFull'=>$orderTotalFull, 'total'=>$order_total, 'tax'=>$order_total_tax, 'totalInclusive'=>$orderTotalInclusive);Change that to this (note the extra lines added too):```
global $currencies;
$prec = $currencies->get_decimal_places();
$order_total = array('totalFull'=>zen_round($orderTotalFull, $prec), 'total'=>zen_round($order_total, $prec), 'tax'=>zen_round($order_total_tax, $prec), 'totalInclusive'=>zen_round($orderTotalInclusive, $prec));

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

23 Nov 2010, 9:46 AM
#32
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Coupons, some bugs?

DrByte:

In that scenario, with a 1000 product, and flat-rate shipping, and setting the ot_coupon module's "Include Shipping" option to false it rejects the 1000 coupon. With the "Include Shipping" option to true, it accepts the coupon.

Yes, but then it includes shipping. And gives discount on a lower amount than intended. We normaly don't want to give discount on the shipping price, only on the products total.

Do you follow my thinking?

Btw! Also discovered same problem, other way around on group pricing - where the customers gets to high discount.

23 Nov 2010, 12:16 PM
#33
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Coupons, some bugs?

With include shipping the coupon will work on:

Sub-Total: Kr.993,75,-

Flat Rate (Best Way): Kr.6,25,-

Discount Coupon: 10off : -Kr.100,00,-

Incl. 25% MVA: Kr.180,00,-

Total: Kr.900,00,-

And when the shipping cost then is 15-25% of the order total ... :no:

23 Nov 2010, 12:29 PM
#34
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Coupons, some bugs?

DrByte:

If so, then the line which you subsequently commented out wouldn't be firing, thus not impacting you, and thus that line is unrelated to your problems.

Did a test now, added:

print_r($this->include_shipping);

before:

if ($this->include_shipping != 'true') $order_total -= $order->info['shipping_cost'];

Output of that is 'truetruetrue', and not 'true' - seems like it's one 'true' for all shipping modules activated. Normal ...? Do you still belive it's not firing. :blink:

23 Nov 2010, 1:20 PM
#36
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Coupons, some bugs?

Some new tests made, with include shipping off.
In this tests the shipping tax is Kr.30, and it seems like this is the amount giving the problems. Why it's removed from total I don't know, but it surly seems to happen without any logic in it.

This works:

Sub-Total: Kr.1.030,00,-
Flat Rate (Best Way): Kr.150,00,-
Discount Coupon: 10off : -Kr.100,00,-
Incl. 25% MVA: Kr.215,40,-
Total: Kr.1.080,00,-

This works NOT:

Sub-Total: Kr.1.029,00,-
Flat Rate (Best Way): Kr.150,00,-
Incl. 25% MVA: Kr.235,80,-
Total: Kr.1.179,00,-

23 Nov 2010, 1:48 PM
#37
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Coupons, some bugs?

Another strange one.
If setting include shipping off and include tax true (re-calculate tax none), the coupon code (10% off) will work on a product with price 1000 - but give wrong discount amount.

Sub-Total: Kr.1.000,00,-
Flat Rate (Best Way): Kr.150,00,-
Discount Coupon: 10off : -Kr.120,00,-
Incl. 25% MVA: Kr.207,00,-
Total: Kr.1.030,00,-

Sorry, I don't find the logic in any settings and tax handling here :no:

23 Nov 2010, 3:47 PM
#38
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Coupons, some bugs?

New test ... When having include shipping/tax false.

Sub-Total: Kr.1.000,00,-
Flat Rate (Best Way): Kr.150,00,-
Incl. 25% MVA: Kr.230,00,-
Total: Kr.1.150,00,-

    if ($this->include_shipping != 'true') $order_total_tax -= $order->info['shipping_tax'];
    print_r($order_total_tax);

Outputs 200

//    if ($this->include_shipping != 'true') $order_total_tax -= $order->info['shipping_tax'];
    print_r($order_total_tax);

Outputs 230

The line is truly firing even if include shipping is false. :yes:

23 Nov 2010, 6:09 PM
#39
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Coupons, some bugs?

We'll look at your shipping concerns again separately.

How did the code fix work for your rounding concerns?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

23 Nov 2010, 6:13 PM
#40
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Coupons, some bugs?

More test, reading and debuging done ... and I think I see what you're doing wrong.

Sub-Total: 1000

First you remove shipping tax:

    if ($this->include_shipping != 'true') $order_total_tax -= $order->info['shipping_tax'];

On next line you remove all tax, including the already removed shipping tax:

    if ($this->include_tax != 'true') $order_total -= $order->info['tax'];

This gives us:

include shipping = false
order total = 770
order total shipping = 150
order total tax = 200

But then you have line commented, witch we can uncomment and change to re-add the shipping tax:

    if ($this->include_tax != "true" && $this->include_shipping != 'true') $order_total += $order->info['shipping_tax'];

This gives us:

include shipping = false
order total = 800
order total shipping = 150
order total tax = 200

That works for us, but I have not tested other scenarios - like tax handling in US etc..