-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout_shipping_address.php
More file actions
executable file
·294 lines (237 loc) · 11.1 KB
/
checkout_shipping_address.php
File metadata and controls
executable file
·294 lines (237 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<?php
/* -----------------------------------------------------------------------------------------
$Id: checkout_shipping_address.php 17 2012-06-04 20:33:29Z deisold $
XT-Commerce - community made shopping
http://www.xt-commerce.com
Copyright (c) 2003 XT-Commerce
-----------------------------------------------------------------------------------------
(c) 2012 Self-Commerce www.self-commerce.de
based on:
(c) 2000-2001 The Exchange Project (earlier name of osCommerce)
(c) 2002-2003 osCommerce(checkout_shipping_address.php,v 1.14 2003/05/27); www.oscommerce.com
(c) 2003 nextcommerce (checkout_shipping_address.php,v 1.14 2003/08/17); www.nextcommerce.org
Released under the GNU General Public License
---------------------------------------------------------------------------------------*/
include ('includes/application_top.php');
// create smarty elements
$smarty = new Smarty;
// include boxes
require (DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/boxes.php');
// include needed functions
require_once (DIR_FS_INC.'xtc_count_customer_address_book_entries.inc.php');
require_once (DIR_FS_INC.'xtc_address_label.inc.php');
require_once (DIR_FS_INC.'xtc_get_address_format_id.inc.php');
require_once (DIR_FS_INC.'xtc_address_format.inc.php');
require_once (DIR_FS_INC.'xtc_get_country_name.inc.php');
require_once (DIR_FS_INC.'xtc_get_countries.inc.php');
require_once (DIR_FS_INC.'xtc_get_zone_code.inc.php');
// Paypal Express Modul Start
if (is_array($_SESSION['nvpReqArray'])) {
$link_checkout_shipping = FILENAME_PAYPAL_CHECKOUT;
if(PAYPAL_EXPRESS_ADDRESS_CHANGE=='true'){
$_SESSION['pp_allow_address_change'] = 'true';
}
} else {
$link_checkout_shipping = FILENAME_CHECKOUT_SHIPPING;
}
// Paypal Express Modul Ende
// if the customer is not logged on, redirect them to the login page
if (!isset ($_SESSION['customer_id'])) {
xtc_redirect(xtc_href_link(FILENAME_LOGIN, '', 'SSL'));
}
// if there is nothing in the customers cart, redirect them to the shopping cart page
if ($_SESSION['cart']->count_contents() < 1) {
xtc_redirect(xtc_href_link(FILENAME_SHOPPING_CART));
}
// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
if ($order->content_type == 'virtual') {
$_SESSION['shipping'] = false;
$_SESSION['sendto'] = false;
xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
$error = false;
$process = false;
if (isset ($_POST['action']) && ($_POST['action'] == 'submit')) {
// process a new shipping address
if (xtc_not_null($_POST['firstname']) && xtc_not_null($_POST['lastname']) && xtc_not_null($_POST['street_address'])) {
$process = true;
if (ACCOUNT_GENDER == 'true')
$gender = xtc_db_prepare_input($_POST['gender']);
if (ACCOUNT_COMPANY == 'true')
$company = xtc_db_prepare_input($_POST['company']);
$firstname = xtc_db_prepare_input($_POST['firstname']);
$lastname = xtc_db_prepare_input($_POST['lastname']);
$street_address = xtc_db_prepare_input($_POST['street_address']);
if (ACCOUNT_SUBURB == 'true')
$suburb = xtc_db_prepare_input($_POST['suburb']);
$postcode = xtc_db_prepare_input($_POST['postcode']);
$city = xtc_db_prepare_input($_POST['city']);
$country = xtc_db_prepare_input($_POST['country']);
if (ACCOUNT_STATE == 'true') {
$zone_id = xtc_db_prepare_input($_POST['zone_id']);
$state = xtc_db_prepare_input($_POST['state']);
}
if (ACCOUNT_GENDER == 'true') {
if (($gender != 'm') && ($gender != 'f')) {
$error = true;
$messageStack->add('checkout_address', ENTRY_GENDER_ERROR);
}
}
if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
$error = true;
$messageStack->add('checkout_address', ENTRY_FIRST_NAME_ERROR);
}
if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
$error = true;
$messageStack->add('checkout_address', ENTRY_LAST_NAME_ERROR);
}
if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
$error = true;
$messageStack->add('checkout_address', ENTRY_STREET_ADDRESS_ERROR);
}
if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
$error = true;
$messageStack->add('checkout_address', ENTRY_POST_CODE_ERROR);
}
if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {
$error = true;
$messageStack->add('checkout_address', ENTRY_CITY_ERROR);
}
if (ACCOUNT_STATE == 'true') {
$zone_id = 0;
$check_query = xtc_db_query("select count(*) as total from ".TABLE_ZONES." where zone_country_id = '".(int) $country."'");
$check = xtc_db_fetch_array($check_query);
$entry_state_has_zones = ($check['total'] > 0);
if ($entry_state_has_zones == true) {
$zone_query = xtc_db_query("select distinct zone_id from ".TABLE_ZONES." where zone_country_id = '".(int) $country."' and (zone_name like '".xtc_db_input($state)."%' or zone_code like '%".xtc_db_input($state)."%')");
if (xtc_db_num_rows($zone_query) > 1) {
$zone_query = xtc_db_query("select distinct zone_id from ".TABLE_ZONES." where zone_country_id = '".(int) $country."' and zone_name = '".xtc_db_input($state)."'");
}
if (xtc_db_num_rows($zone_query) >= 1) {
$zone = xtc_db_fetch_array($zone_query);
$zone_id = $zone['zone_id'];
} else {
$error = true;
$messageStack->add('create_account', ENTRY_STATE_ERROR_SELECT);
}
} else {
if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {
$error = true;
$messageStack->add('checkout_address', ENTRY_STATE_ERROR);
}
}
}
if ((is_numeric($country) == false) || ($country < 1)) {
$error = true;
$messageStack->add('checkout_address', ENTRY_COUNTRY_ERROR);
}
if ($error == false) {
$sql_data_array = array ('customers_id' => $_SESSION['customer_id'], 'entry_firstname' => $firstname, 'entry_lastname' => $lastname, 'entry_street_address' => $street_address, 'entry_postcode' => $postcode, 'entry_city' => $city, 'entry_country_id' => $country);
if (ACCOUNT_GENDER == 'true')
$sql_data_array['entry_gender'] = $gender;
if (ACCOUNT_COMPANY == 'true')
$sql_data_array['entry_company'] = $company;
if (ACCOUNT_SUBURB == 'true')
$sql_data_array['entry_suburb'] = $suburb;
if (ACCOUNT_STATE == 'true') {
if ($zone_id > 0) {
$sql_data_array['entry_zone_id'] = $zone_id;
$sql_data_array['entry_state'] = '';
} else {
$sql_data_array['entry_zone_id'] = '0';
$sql_data_array['entry_state'] = $state;
}
}
xtc_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
$_SESSION['sendto'] = xtc_db_insert_id();
// Paypal Express Modul Änderung:
xtc_redirect(xtc_href_link($link_checkout_shipping, '', 'SSL'));
}
// process the selected shipping destination
}
elseif (isset ($_POST['address'])) {
$reset_shipping = false;
if (isset ($_SESSION['sendto'])) {
if ($_SESSION['sendto'] != $_POST['address']) {
if (isset ($_SESSION['shipping'])) {
$reset_shipping = true;
}
}
}
$_SESSION['sendto'] = $_POST['address'];
$check_address_query = xtc_db_query("select count(*) as total from ".TABLE_ADDRESS_BOOK." where customers_id = '".$_SESSION['customer_id']."' and address_book_id = '".$_SESSION['sendto']."'");
$check_address = xtc_db_fetch_array($check_address_query);
if ($check_address['total'] == '1') {
if ($reset_shipping == true) {
unset ($_SESSION['shipping']);
}
// Paypal Express Modul Änderung:
xtc_redirect(xtc_href_link($link_checkout_shipping, '', 'SSL'));
} else {
unset ($_SESSION['sendto']);
}
} else {
$_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
// Paypal Express Modul Änderung:
xtc_redirect(xtc_href_link($link_checkout_shipping, '', 'SSL'));
}
}
// if no shipping destination address was selected, use their own address as default
if (!isset ($_SESSION['sendto'])) {
$_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
}
// Paypal Express Modul Änderung:
$breadcrumb->add(NAVBAR_TITLE_1_CHECKOUT_SHIPPING_ADDRESS, xtc_href_link($link_checkout_shipping, '', 'SSL'));
$breadcrumb->add(NAVBAR_TITLE_2_CHECKOUT_SHIPPING_ADDRESS, xtc_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL'));
$addresses_count = xtc_count_customer_address_book_entries();
require (DIR_WS_INCLUDES.'header.php');
$smarty->assign('FORM_ACTION', xtc_draw_form('checkout_address', xtc_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL'), 'post', 'onsubmit="return check_form_optional(checkout_address);"'));
if ($messageStack->size('checkout_address') > 0) {
$smarty->assign('error', $messageStack->output('checkout_address'));
}
if ($process == false) {
$smarty->assign('ADDRESS_LABEL', xtc_address_label($_SESSION['customer_id'], $_SESSION['sendto'], true, ' ', '<br />'));
if ($addresses_count > 1) {
$address_content = '<table width="100%" cellspacing="0" cellpadding="5" border="0">';
$radio_buttons = 0;
$addresses_query = xtc_db_query("select address_book_id, entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from ".TABLE_ADDRESS_BOOK." where customers_id = '".$_SESSION['customer_id']."'");
while ($addresses = xtc_db_fetch_array($addresses_query)) {
$format_id = xtc_get_address_format_id($address['country_id']);
$address_content .= '';
if ($addresses['address_book_id'] == $_SESSION['sendto']) {
$address_content .= '<tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, '.$radio_buttons.')">'."\n";
} else {
$address_content .= '<tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, '.$radio_buttons.')">'."\n";
}
$address_content .= '<td width="10%">'.xtc_draw_radio_field('address', $addresses['address_book_id'], ($addresses['address_book_id'] == $_SESSION['sendto'])).'</td>
<td><strong>'.$addresses['firstname'].' '.$addresses['lastname'].'</strong></td>
</tr>
<tr>
<td colspan="2">'.xtc_address_format($format_id, $addresses, true, ' ', ', ').'</td>
</tr>
<tr>
<td colspan="2" height="5"> </td>
</tr>';
$radio_buttons ++;
}
$address_content .= '</table>';
$smarty->assign('BLOCK_ADDRESS', $address_content);
}
}
if ($addresses_count < MAX_ADDRESS_BOOK_ENTRIES) {
require (DIR_WS_MODULES.'checkout_new_address.php');
}
$smarty->assign('BUTTON_CONTINUE', xtc_draw_hidden_field('action', 'submit').xtc_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE));
$smarty->assign('FORM_END', '</form>');
$smarty->assign('language', $_SESSION['language']);
$smarty->caching = 0;
$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/checkout_shipping_address.html');
$smarty->assign('language', $_SESSION['language']);
$smarty->assign('main_content', $main_content);
$smarty->caching = 0;
if (!defined(RM)) {
$smarty->loadfilter('output', 'note');
}
$smarty->display(CURRENT_TEMPLATE.'/index.html');
include ('includes/application_bottom.php');