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.
19 /* This class is used to add the shipping options for the cart
20 * There are 3 types of shipping supported
21 * 1. Flat (Type:flat-rate)
22 * 2. Pickup (Type:pickup)
23 * 3. Merchant calculated (Type:merchant-calculated)
25 * Invoke a separate instance of this class for each type of shipping
27 * Required fields are shipping name, shipping type and price
28 * Allowed and excluded country areas can be specified as part of constructor
29 * arguments or using individual Set methods. Possible values here are
33 * State and zip patterns must be exclusively updated using their individual Set methods
35 class GoogleShipping
{
42 var $allowed_state_areas_arr;
43 var $allowed_zip_patterns_arr;
44 var $excluded_state_areas_arr;
45 var $excluded_zip_patterns_arr;
46 var $allowed_country_area;
47 var $excluded_country_area;
48 var $allowed_restrictions = FALSE;
49 var $excluded_restrictions = FALSE;
55 * @param string $money
56 * @param string $allowed_country_area
57 * @param string $excluded_country_area
59 function GoogleShipping($name, $type, $price, $money = "USD",
60 $allowed_country_area = "",
61 $excluded_country_area = ""
63 $this->price
= $price;
65 $this->type
= strtolower($type);
66 $this->currency
= $money;
68 if ($allowed_country_area != "") {
70 $this->SetAllowedCountryArea($allowed_country_area);
73 if ($excluded_country_area != "") {
75 $this->SetExcludedCountryArea($excluded_country_area);
78 $this->allowed_state_areas_arr
= array();
79 $this->allowed_zip_patterns_arr
= array();
80 $this->excluded_state_areas_arr
= array();
81 $this->excluded_zip_patterns_arr
= array();
87 function SetAllowedStateAreas($areas) {
88 $this->allowed_restrictions
= TRUE;
89 $this->allowed_state_areas_arr
= $areas;
95 function SetAllowedZipPattens($zips) {
96 $this->allowed_restrictions
= TRUE;
97 $this->allowed_zip_patterns_arr
= $zips;
103 function SetExcludedStateAreas($areas) {
104 $this->excluded_restrictions
= TRUE;
105 $this->excluded_state_areas_arr
= $areas;
111 function SetExcludedZipPatternsStateAreas($zips) {
112 $this->excluded_restrictions
= TRUE;
113 $this->excluded_zip_patterns_arr
= $zips;
117 * @param $country_area
119 function SetAllowedCountryArea($country_area) {
120 if ($country_area == "CONTINENTAL_48" ||
121 $country_area == "FULL_50_STATES" ||
122 $country_area = "ALL"
124 $this->allowed_country_area
= $country_area;
125 $this->allowed_restrictions
= TRUE;
127 else $this->allowed_country_area
= "";
131 * @param $country_area
133 function SetExcludedCountryArea($country_area) {
134 if ($country_area == "CONTINENTAL_48" ||
135 $country_area == "FULL_50_STATES" ||
136 $country_area = "ALL"
138 $this->excluded_country_area
= $country_area;
139 $this->excluded_restrictions
= TRUE;
141 else $this->excluded_country_area
= "";