tools - add missing comment blocks
[civicrm-core.git] / tools / extensions / org.civicrm.payment.googlecheckout / packages / Google / library / googleshipping.php
1 <?php
2
3 /**
4 * Copyright (C) 2006 Google Inc.
5 *
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
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
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.
17 */
18
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)
24 *
25 * Invoke a separate instance of this class for each type of shipping
26 * to be included
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
30 * 1. CONTINENTAL_48
31 * 2. FULL_50_STATES
32 * 3. ALL
33 * State and zip patterns must be exclusively updated using their individual Set methods
34 */
35 class GoogleShipping {
36
37 var $type;
38 var $price;
39 var $currency;
40 var $name;
41
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;
50
51 /**
52 * @param $name
53 * @param $type
54 * @param $price
55 * @param string $money
56 * @param string $allowed_country_area
57 * @param string $excluded_country_area
58 */
59 function GoogleShipping($name, $type, $price, $money = "USD",
60 $allowed_country_area = "",
61 $excluded_country_area = ""
62 ) {
63 $this->price = $price;
64 $this->name = $name;
65 $this->type = strtolower($type);
66 $this->currency = $money;
67
68 if ($allowed_country_area != "") {
69
70 $this->SetAllowedCountryArea($allowed_country_area);
71 }
72
73 if ($excluded_country_area != "") {
74
75 $this->SetExcludedCountryArea($excluded_country_area);
76 }
77
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();
82 }
83
84 /**
85 * @param $areas
86 */
87 function SetAllowedStateAreas($areas) {
88 $this->allowed_restrictions = TRUE;
89 $this->allowed_state_areas_arr = $areas;
90 }
91
92 /**
93 * @param $zips
94 */
95 function SetAllowedZipPattens($zips) {
96 $this->allowed_restrictions = TRUE;
97 $this->allowed_zip_patterns_arr = $zips;
98 }
99
100 /**
101 * @param $areas
102 */
103 function SetExcludedStateAreas($areas) {
104 $this->excluded_restrictions = TRUE;
105 $this->excluded_state_areas_arr = $areas;
106 }
107
108 /**
109 * @param $zips
110 */
111 function SetExcludedZipPatternsStateAreas($zips) {
112 $this->excluded_restrictions = TRUE;
113 $this->excluded_zip_patterns_arr = $zips;
114 }
115
116 /**
117 * @param $country_area
118 */
119 function SetAllowedCountryArea($country_area) {
120 if ($country_area == "CONTINENTAL_48" ||
121 $country_area == "FULL_50_STATES" ||
122 $country_area = "ALL"
123 ) {
124 $this->allowed_country_area = $country_area;
125 $this->allowed_restrictions = TRUE;
126 }
127 else $this->allowed_country_area = "";
128 }
129
130 /**
131 * @param $country_area
132 */
133 function SetExcludedCountryArea($country_area) {
134 if ($country_area == "CONTINENTAL_48" ||
135 $country_area == "FULL_50_STATES" ||
136 $country_area = "ALL"
137 ) {
138 $this->excluded_country_area = $country_area;
139 $this->excluded_restrictions = TRUE;
140 }
141 else $this->excluded_country_area = "";
142 }
143 }
144