Build Your Own Business Website header image

How to Setup California Local Sales Tax in Shopp Part 4 – Get the Correct Rate for the City

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 show how to get the correct rate for the city using a key to take the value of the city and the shipping value of city and place it in a variable. We compare the city name with the city that is inside the city shipping address and compare the city to the California rates. We use conditional statements to return the rate depending upon whether or not the city exists in California.

Video Transcript

The next thing to do is to compare the city name with the city that is inside of the city shipping address because that’s what this is based on. So then what we do is get the Shopp city. The city is equal to Shopp shopping data order shipping city, right? Then we compare the city to the California rates and if that city exists then we’ll use the California rate. And if it doesn’t then we won’t.

Here’s the end of our array. Let’s tab this over. So now our city equals Shopp shopping data. Then what we’re going to say is local rate equals so take out the… well, we’re not going to use the if yet. Then we’re going to say local rate equals and then that is local rates and then we need to specify the key and that the key is going to be city. So local rate equals local rates city.

What this does then is this is the key that we’re looking for. So we’ve taken this value of city and we’ve taken the shipping value of city and we place it in this variable. Then we’ve said local rates that city, look through this for that city and then place the value of this key in this variable called local rate. And then we say if… well, pardon me. We’re going to use this if statement. If local rate is greater than 0… actually, if local rate is not greater than 0… she doesn’t like that, does it?

Let’s see, let’s say that instead. If local rate is not equal to blank… that’s probably a better way to do it because if there is no value, it’s going to return blank. So if local rate is not equal to blank then $rate equals local rate. Okay so it’ll substitute the local rate for rate. Else, $rate equals… and at this point, what we’re going to do is we’re going to charge the default value or the lowest possible value which looks to me like it’s 7.25 so the rate equals 0.0725.

Here’s the logic. The logic is, we get the city from our form and we search this list for that city. If that city exists that is, if local rates has that city as a key then we place the value of that element of the array in the variable local rate. Then if local rate is blank that is, if it’s none of these cities, then rate… I’m sorry. If local rate isn’t blank that is, if it is one of these cities then local rate equals local rate. If it’s not one of those cities then rate equals 0.725 which is the lowest of the rates and then we return the rate.

So we have two places in which we might return the rate. We might return the rate if it’s not California then we’ll return the rate. And if it is California, we’ll return the rate after we figure out whether or not there’s a local rate that affects it.

0 Comments… add one
0 comments… add one