Build Your Own Business Website header image

How to Setup California Local Sales Tax in Shopp Part 5 – Test the Function

Difficulty Level -

Filed Under Topics - ,

Listed Under Lesson Subjects -

Whoops, you've found some premium content!

Watch the opening clip of this video to preview it,
the full video is available to paid members.

In this session we test the function and get rid of special characters that might affect the tax calculation. We also clean the city names up by applying filters to eliminate some of the errors.

Video Transcript

Rick:  The other iteration on this, although we should just check this, right now if there’s any typo, there’s not going to be… you know, this is dependent upon them typing Woodland Hills exactly that way. So that has some potential problems. What happens if somebody types in Woodland Hills in lowercase?

Member:  Well, this is a stupid question. I mean, does that… does one letter being off, will that affect the credit transaction? You know, like if you misspell your name, sometimes the credit card company will kick that back. Is that the case with city name as well?

Rick:  I doubt that it will kill the transaction but it will throw off the calculation for tax. What we did in our other project was we took this information and we sanitized it. By sanitizing it, what I mean is we got rid of all of those spaces and commas and you know, all that kind of stuff. We got rid of the capitals and everything else and we tested against that instead.

What we have here actually is first off, we iterate through that list. So for each of those as key value, we create a clean key which is essentially string to lower. It makes everything lowercase and it replaces all of the other oddball characters with nothing. So it gets rid of all the spaces and everything else and you have one word that is all lowercase with no special characters.

Member:  Gotcha, okay.

Rick:  Now you have a new array and then that new array then is compared against a clean city so you do exactly the same thing with that city name. Clean the city name up by applying that same filter to the city. It doesn’t solve misspelling but it eliminates special characters, spaces and uppercase, lowercase errors. So it takes out some of the error. So in fact, that’s what we’re going to do here. We’re just going to take that next step. Well actually, before I do that, what I really want to do is upload this and test it.

Okay so 90002. Shipping estimate, proceed to checkout, okay. Okay so give me a California billing address, 1234 Main Street but give me a real city and zip.

Member:  You could use Redondo Beach.

Rick:  Redondo Beach and that is California, USA. Oh pardon me, that goes here. Okay and what’s the zip there?

Member:  90277.

Rick:  Okay let’s proceed to checkout and see what happens. I think I have this set up to use the… okay so in this case, it used $2.62 so the question really is is that the same for Redondo?

Member:  That will total to, I think, 8.725 or something close to that. Let me me see if that’s Redondo.

Rick:  Redondo Beach, 8.75. So that’s the same as our… so that doesn’t actually help us because it’s the same use case as the maximum. So let’s use Richfield.

Member:  On the list, look at… well, you’re close. Just go down to the T’s as in Thomas or I guess you can use any of these. It doesn’t matter.

Rick:  Okay but…

Member:  Try one with a space in it to see if your formula works, Thousand Oaks.

Rick:  I haven’t put that formula in yet so…

Member:  Oh okay, sorry.

Rick:  But absolutely. Let’s come back to this. Let’s see, edit shopping cart. No, proceed to checkout and let’s put a different… let’s put that in, Tarabella. And this should be less than $2.62. Now it’s $2.33. Okay…

Member:  That’s right.

Rick:  We can go back to edit the shopping cart and let’s see, proceed to checkout. Now, we get rid of the space and proceed to checkout. It’s going to screw up the thing, $2.17. We didn’t find it so that it used the lower value, okay.

0 Comments… add one
0 comments… add one

Leave a Comment