If this is your first visit, check our documentation. To post, register or login.
Forums / Code Matters / Bug Reports / ZC 1.3.0.2 will not calculate tax, entering state/province bug

ZC 1.3.0.2 will not calculate tax, entering state/province bug

Locked

Started by tj1 on 10 Jul 2006, 8:17 PM · Views: 14,360

Results 21 to 40 of 41
This thread is locked. New replies are disabled.
4 Aug 2006, 3:02 PM
#21
joanorsky avatar

joanorsky

New Zenner

Join Date:
Jul 2006
Posts:
25
Plugin Contributions:
0

Post #21 by joanorsky

Ok guys... i think i've found a fix...

After some analisys i think i found it... well.. if this "add address" process is ok when creating a new account this would mean that the code is already implemented. So the problem was that this wasn't being checked when adding a new address from on other page besides the initial "new account".

I found that the code in question is :

  if (ACCOUNT_STATE == 'true' && ACCOUNT_STATE_DRAW_INITIAL_DROPDOWN == 'true') {
    $zone_id = 0;
    $check_query = "select count(*) as total
                      from " . TABLE_ZONES . "
                      where zone_country_id = '" . (int)SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY . "'";
    $check = $db->Execute($check_query);
    $entry_state_has_zones = ($check->fields['total'] > 0);
    if ($entry_state_has_zones == true) {
      $zones_array = array();
      $zones_array[] = array('id' => PULL_DOWN_ALL, 'text' => PULL_DOWN_ALL);
      $zones_values = $db->Execute("select zone_name
                                   from " . TABLE_ZONES . "
                                   where zone_country_id = '" . (int)SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY . "'
                                   order by zone_name");
      while (!$zones_values->EOF) {
        $zones_array[] = array('id' => $zones_values->fields['zone_name'], 'text' => $zones_values->fields['zone_name']);
        $zones_values->MoveNext();
      }
    }
  }

where ```php
ACCOUNT_STATE_DRAW_INITIAL_DROPDOWN == 'true'



So.. my advise is always to backup before doing what i am going to explain next.

Hey.. BACKUP!! 


Just insert this piece of code on the **includes/modules/checkout_new_address.php** so it becomes like this :
**(comented code is new to the file)**

```php
<?php
/**
 * checkout_new_address.php
 *
 * @package modules
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: checkout_new_address.php 3777 2006-06-15 07:03:03Z drbyte $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}


/** 
 * NEW CODE FROM THIS POINT ON
 */


 if (ACCOUNT_STATE == 'true' && ACCOUNT_STATE_DRAW_INITIAL_DROPDOWN == 'true') {
    $zone_id = 0;
    $check_query = "select count(*) as total
                      from " . TABLE_ZONES . "
                      where zone_country_id = '" . (int)SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY . "'";
    $check = $db->Execute($check_query);
    $entry_state_has_zones = ($check->fields['total'] > 0);
    if ($entry_state_has_zones == true) {
      $zones_array = array();
      $zones_array[] = array('id' => PULL_DOWN_ALL, 'text' => PULL_DOWN_ALL);
      $zones_values = $db->Execute("select zone_name
                                   from " . TABLE_ZONES . "
                                   where zone_country_id = '" . (int)SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY . "'
                                   order by zone_name");
      while (!$zones_values->EOF) {
        $zones_array[] = array('id' => $zones_values->fields['zone_name'], 'text' => $zones_values->fields['zone_name']);
        $zones_values->MoveNext();
      }
    }
  }[/B]

/** 
 * NEW CODE ENDED HERE
 */

/**
 * determine pulldown menu contents if appropriate
 */

Give it a try... and post some feedback. Hope i got it... and remember.. always backup!! ;) :thumbsup:

8 Aug 2006, 3:31 PM
#22
ladyhlg avatar

ladyhlg

Zen Follower

Join Date:
May 2005
Posts:
361
Plugin Contributions:
1

Post #22 by ladyhlg

joanorsky,
This fix seems to be working for me.
Thanks!!
LadyHLG

8 Aug 2006, 6:23 PM
#23
dbrewster avatar

dbrewster

Zen Follower

Join Date:
Jul 2005
Location:
Charlottesville, VA
Posts:
376
Plugin Contributions:
0

Post #23 by dbrewster

It looks like this fix only works if admin > configuration > customer details > state always display as pulldown = true.

Unfortunately, if you are sending anywhere but the US, that method forces non-US addresses to choose US states, right?

Anyone have a fix for this? It's a sale-killer.

Since we have very few international orders I might use it for now.

---Diana

11 Aug 2006, 4:40 PM
#24
joanorsky avatar

joanorsky

New Zenner

Join Date:
Jul 2006
Posts:
25
Plugin Contributions:
0

Post #24 by joanorsky

dbrewster:

It looks like this fix only works if admin > configuration > customer details > state always display as pulldown = true.

Unfortunately, if you are sending anywhere but the US, that method forces non-US addresses to choose US states, right?

Anyone have a fix for this? It's a sale-killer.

Since we have very few international orders I might use it for now.

---Diana

Well this fix is only for the pulldown = true condition... but it works on all countries. You just have to insert the zones manually.. otherwise it will fail.. of course..

... maybe i did not understood your meaning... :unsure:

17 Aug 2006, 4:08 PM
#25
dbrewster avatar

dbrewster

Zen Follower

Join Date:
Jul 2005
Location:
Charlottesville, VA
Posts:
376
Plugin Contributions:
0

Post #25 by dbrewster

joanorsky:

Well this fix is only for the pulldown = true condition... but it works on all countries. You just have to insert the zones manually.. otherwise it will fail.. of course.

Well, even for countries that have some zones in the database, the drop menu does not show them. If I say I am shipping to Switzerland, I see a drop list with... US states in it.

So, international shipping is broken for me until we have a fix. :cry:

Not that we do much of that at all, but, still.

but perhaps I have a misconfiguration somewhere? suggestions??

26 Aug 2006, 9:01 PM
#26
giselegrenier avatar

giselegrenier

New Zenner

Join Date:
Aug 2006
Posts:
27
Plugin Contributions:
0

Post #26 by giselegrenier

This fixed it!!!

I just had to remove: [/b] from the posted code and after doing 1 hour of testing with the address book, taxes are being charged correctly.

Thanks so much for posting the solution!

Gisèle Grenier

28 Aug 2006, 2:08 PM
#27
dbrewster avatar

dbrewster

Zen Follower

Join Date:
Jul 2005
Location:
Charlottesville, VA
Posts:
376
Plugin Contributions:
0

Post #27 by dbrewster

This code still does not handle where a country has no zones in the zones table (i.e. states or provinces), when you choose state droplist required.

There is another bug with this code: if you want to change your mailing address to a different country, you only see a drop list for states for your original country.

We have lost some international orders because of this... however, we have very few international orders, so it's not a big issue for us.

If I remove the requirement for the drop list of states, then international orders work (except for those countries that always mysteriously fail USPS delivery, such as Cyprus and Switzerland, which may be due to a bug in USPS code.)

---Diana

31 Aug 2006, 7:03 AM
#28
imac avatar

imac

New Zenner

Join Date:
Mar 2006
Location:
Durham, UK
Posts:
78
Plugin Contributions:
0

Post #28 by imac

Ajeh:

A nice fix is coming ... thanks for the updates ... :smile:There's an old adage that says that out of 'quick', 'cheap' and 'good', you can't have more than 2 at the same time. So if it's 'free' and you want it 'good', then it can't be quick. All of which is by way of saying that I'm ashamed to admit that news of a Zen core-team fix for what has always been one of the major bug-bears in the osC/Zen create account interface - the defined State/Zone kick-back problem - put me in a state roughly equivalent to a 5-year-old waiting for Christmas. If Ajeh says it's good, then it must be good! I know that asking when it might be ready is about as inappropriate as asking Father Christmas to get-a-move-on down the chimney. But I can't help myself. Just don't kick me too hard! Pleez? :lamo:

1 Sep 2006, 6:11 AM
#29
medicman47 avatar

medicman47

New Zenner

Join Date:
Sep 2006
Posts:
10
Plugin Contributions:
0

Post #29 by medicman47

Help! My includes/modules/checkout_new_address.php file doesn't look anything like the one with the fix. It is only two lines of code long! It only mentions templates. Also, I have noticed that with an existing address or one on file it is not adding tax nor adding weights to change the shipping! Any thoughts?

John

1 Sep 2006, 7:01 AM
#30
imac avatar

imac

New Zenner

Join Date:
Mar 2006
Location:
Durham, UK
Posts:
78
Plugin Contributions:
0

Post #30 by imac

medicman47:

Help! My includes/modules/checkout_new_address.php file doesn't look anything like the one with the fix. It is only two lines of code long! It only mentions templates.Check which ZC version you installed. (-> Admin -> Tools -> Server Info).

Is it 1.2.x?

The code was changed quite significantly for the 1.3 series. As far as I'm aware this particular bug only appeared in v.1.3.0.2 - which is what this thread refers to :smile:> medicman47:

Also, I have noticed that with an existing address or one on file it is not adding taxCheck:
i) the addresses you're testing are located within a Zone defined in -> Admin -> Locations / Taxes -> Zones Definitions
ii) the tax class(es) relevant to those addresses are defined in -> Admin -> Locations / Taxes -> Tax Classes
iii) the relevant Tax Classes are linked to the relevant defined zones with the relevant tax rate in -> Admin -> Locations / Taxes -> Tax Rates
medicman47:

nor adding weights to change the shipping! Any thoughts?Check:
i) the products in your cart have weights assigned in ->Admin -> Catalog -> Categories/Products
ii) your shipping method is based on weight rather than price (-> Admin -> Modules -> Shipping -> )

1 Sep 2006, 4:45 PM
#31
medicman47 avatar

medicman47

New Zenner

Join Date:
Sep 2006
Posts:
10
Plugin Contributions:
0

Post #31 by medicman47

Okay, I am using an old version. I am using 1.2.6. Sorry, I just started using this a couple of days ago. I am still trying to get my mind around it. Let me try an update! Thanks for your help on this. I was starting to think I had messed up somewhere!

John

1 Sep 2006, 8:02 PM
#32
imac avatar

imac

New Zenner

Join Date:
Mar 2006
Location:
Durham, UK
Posts:
78
Plugin Contributions:
0

Post #32 by imac

medicman47:

I just started using this a couple of days ago.Guessed that might be the case :smile: > medicman47:

Thanks for your help on this.No probs. Pleased to be able to help out. > medicman47:

I was starting to think I had messed up somewhere!Can't remember I day when I was sure that I hadn't. :unsure:

2 Sep 2006, 3:13 AM
#33
medicman47 avatar

medicman47

New Zenner

Join Date:
Sep 2006
Posts:
10
Plugin Contributions:
0

Post #33 by medicman47

Upgrade complete. Still no luck with the taxes. I have gone in and reconfigured them through the admin side. It will not add tax at all. New address, address on file, it doesn't seem to matter. Someone please tell me that this isn't a terminal problem!

John

2 Sep 2006, 3:18 AM
#34
drbyte avatar

drbyte

Sensei

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

Post #34 by drbyte

I wrote (actually, adapted) this article on configuring taxes for Canada. Perhaps you may want to check that you have in fact set up all your zone-definitions (with states applied to them properly), tax classes, and tax rates .... as well as have set all your product to use the Tax Class you have in your store, or at least whichever one is applicable to the products.
http://www.zen-cart.com/forum/showthread.php?t=35032

.
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.

2 Sep 2006, 8:36 PM
#35
imac avatar

imac

New Zenner

Join Date:
Mar 2006
Location:
Durham, UK
Posts:
78
Plugin Contributions:
0

Post #35 by imac

medicman47:

Someone please tell me that this isn't a terminal problem!Why leap to the conclusion that it's a terminal problem when there are thousands of other installations out there running OK, and more than 30k users on these forums who might have a lot of other problems, but don't seem to be having this one? :smile:

I'm not trying to be funny. It's a serious question.

The illusion that the likes of Microsoft have succeeded in selling to the world is that computing is all about hitting one button to install the stuff, and then another few buttons and -flash-bang-wallop- it's as easy as pie. All you have to do us bung them eveything you have in your wallet and let them install a toll-gate in your living room.

Unfortunately, that is very far from the actual truth of the matter.

Computers have never been anything more than dull, nit-picking, plodding morons. They might be able to crunch numbers faster than the pearly Gates can syphon dosh out of your bank account. But they have absolutely no idea what they are doing unless, somewhere along the line, some human has told them exactly what that is.

I may be in danger of telling my grandmother how to suck eggs here. If so, I apologise. All I'm trying to say is that if you want a computer to do what you want it to do you have to go some way to try talk to it on its own level. That means adopting, at least in part, a plodding, nit-picking, one-step-at-a-time, is that switched on or is it off? kind of attitude.

So. To get to the bottom of your particular problem, you would need to describe exactly what data you put in where. And exactly what result came out at which end. If you do that, then 9 times out of 10 the answer will materialise of its own accord. Leaving you with nothing more to do than give yourself a good kicking for not being as daft as the the dumb-beast of a computer you are trying to bend to your thrall.

Under all normal circumstances, all versions of Zen Cart calculate tax with absolutely no problem at all. 30,000 users can testify to that.

I, for one, am curious to know which bit of the setup process is causing the problem? And only you can tell us exactly what that is :smile:

3 Sep 2006, 4:45 AM
#36
medicman47 avatar

medicman47

New Zenner

Join Date:
Sep 2006
Posts:
10
Plugin Contributions:
0

Post #36 by medicman47

Actually, the article that DrByte forwarded to me helped out a lot. I only had Texas sales tax in. Once I added a second sales tax, it started calculating taxes for me. A little bit more effort and a lot more time later, I was up and running.

The upgrade from 1.2.6d to 1.3.0.2 was frustrating but was accomplished. I have an error that sys my database needs to be patched to a higher level, but other than that it appears to be stable and functioning perfectly.

I don't have any experience with working on servers and only minimal experience doing html. This whole process has really opened my eyes to how this process works. Are there any good books that anyone would recommend to me so that I can learn more about all of this before I NEED to learn more about it? Knowledge is power, right?

Anyway, thanks DrByte! That article was great. I even went so far as to print it out and file it for future reference!

John:yes:

3 Sep 2006, 4:53 AM
#37
medicman47 avatar

medicman47

New Zenner

Join Date:
Sep 2006
Posts:
10
Plugin Contributions:
0

Post #37 by medicman47

Oh, I almost forgot. Imac, I am a paramedic (20 years and counting) so when I say terminal problem I meant incurable or fatal. I honestly thought that I had screwed something up or wasn't doing something right. After I wrote the post I realized that it wouldn't translate very accurately into a discussion about computers. When I logged back on to clarify the statement, I saw the article from DrByte and read it, then worked on the issue until it was resolved. Needless to say, I forgot to go back and clarify the statement. Sorry for the confusion.

John

3 Sep 2006, 9:58 AM
#38
imac avatar

imac

New Zenner

Join Date:
Mar 2006
Location:
Durham, UK
Posts:
78
Plugin Contributions:
0

Post #38 by imac

medicman47:

Oh, I almost forgot. Imac, I am a paramedic (20 years and counting) so when I say terminal problem I meant incurable or fatal. I honestly thought that I had screwed something up or wasn't doing something right. I kinda guessed it must be something like that! I knew the good Doc's advice would be right on-the-money as always. But you hadn't posted back yet, so I assumed it wasn't working. All I thought I might be able to add was a peek into my what is, in my experience (40 years dealing with computers since the days when there was no such thing as computer screens and disc drives were the size of washing machines) the kind of mind-set one needs to adopt to debug these things.

Key words here are 'guessed' and 'assumed.' That's where I got it wrong. That's where it usually does go wrong. :lamo:

Intuitive leaps of imagination can cut out a lot of the tiresome leg-work - provided you're lucky enough to make the right leap. But they can just as easily take you 180 degrees in the wrong direction. Only the data decides.

Working with humans in traumatic situations (which I have very little experience of at all - even the thought scares me half to death :shocking: ) I guess (there's that word again!) that one basic truth of life must be hammered home in the strongest way possible on a routine basis. All living things have to go terminal at some point or another.

But the mind-set switch I was trying to push is the idea that machines aren't living things. They were never really alive in the first place, so they can't really die. No doubt somebody will put me right on this, and I hope they do, but I can't think of any machine that couldn't be kept going forever, if that's what we wanted. Parts may break or wear out. But they can always be replaced by others. Organ transplanters might have us believe that people are like that too. If only that were really true! > medicman47:

I honestly thought that I had screwed something up or wasn't doing something right.Well... actually... isn't that true? When you acted on the good Doctor's advice and started doing the right thing then it stopped screwing up. Point here being that in your day-job, not doing something right can often have irreversible and tragic consequences. If I did your job I guess (that word again!) that would be top of my mind-set most of the time.

But Zen Cart isn't a life-support machine, it's a shopping trolley! You can always restore the machine, if not the people attached to it. So screwing up in this kind of virtual-reality world is no big-deal. There are no really serious consequences, so we can easily own-up to it if we do. What a luxury! An ideal way to relax after the rigours of your day-job perhaps?

medicman47:

Needless to say, I forgot to go back and clarify the statement. Sorry for the confusion. No probs. Thanks for the update. :thumbsup: If you get stuck somewhere it's more than likely that somebody else is too. The more things get written up here, the more help that might be. Which, I guess, is probably why most of us are here in the first place!

9 Sep 2006, 11:56 AM
#39
imac avatar

imac

New Zenner

Join Date:
Mar 2006
Location:
Durham, UK
Posts:
78
Plugin Contributions:
0

Post #39 by imac

Ajeh:

A nice fix is coming ... :smile:Just wanted to say a very big THANX to Ajeh, the good Doc, and all the rest of the Zen team for building such a beautifully elegant fix. The zone field kick-back thing has always been a major bugbear for many customers, but this new drop down is a dream. Is Zen THE BUSINESS or wot?:jump:

11 Sep 2006, 7:44 PM
#40
dbrewster avatar

dbrewster

Zen Follower

Join Date:
Jul 2005
Location:
Charlottesville, VA
Posts:
376
Plugin Contributions:
0

Post #40 by dbrewster

imac:

Just wanted to say a very big THANX to Ajeh, the good Doc, and all the rest of the Zen team for building such a beautifully elegant fix.

Ditto on that, it's a beautiful fix. Is that Ajax? :p

One small detail... will you be applying the fix to the popup shipping estimator window, too? It suffers from the same state update problem.

Diana