4 * Copyright (C) 2006 Google Inc.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 /* This class is used to create Tax rules to be added to the tax tables
19 * in the shopping cart
20 * Ther are two types of tax rules
21 * 1. default (should be added to a default tax table)
22 * 2. alternate (should be added to an alternate tax table)
24 * Invoke a separate instance of this class for each tax rule to be
26 * Required fields are the rule type and the tax rate
27 * Country area can be specified as part of constructor arguments or
28 * using individual Set methods. Possible values here are
32 * State and zip patterns must be exclusively updated using their
33 * individual Set methods
42 var $zip_patterns_arr;
48 * @param string $country_area
49 * @param string $shipping_taxed
51 function GoogleTaxRule($type, $tax_rate, $country_area = "",
52 $shipping_taxed = "false"
54 $this->rax_rule_type
= strtolower($type);
55 $this->shipping_taxed
= $shipping_taxed;
56 $this->tax_rate
= $tax_rate;
58 if ($country_area != "") {
60 $this->SetCountryArea($country_area);
63 $this->state_areas_arr
= array();
64 $this->zip_patterns_arr
= array();
70 function SetStateAreas($areas) {
71 if (is_array($areas)) {
72 $this->state_areas_arr
= $areas;
74 else $this->state_areas_arr
= array($areas);
80 function SetZipPatterns($zips) {
81 if (is_array($zips)) {
82 $this->zip_patterns_arr
= $zips;
84 else $this->zip_patterns_arr
= array($zips);
88 * @param $country_area
90 function SetCountryArea($country_area) {
91 if ($country_area == "CONTINENTAL_48" ||
$country_area == "FULL_50_STATES"
92 ||
$country_area = "ALL"
93 ) $this->country_area
= $country_area;
94 else $this->country_area
= "";