[ Index ] |
|
Code source de osCommerce 2.2ms2-060817 |
1 <?php 2 /* 3 $Id: checkout_shipping.php,v 1.16 2003/06/09 23:03:53 hpdl Exp $ 4 5 osCommerce, Open Source E-Commerce Solutions 6 http://www.oscommerce.com 7 8 Copyright (c) 2003 osCommerce 9 10 Released under the GNU General Public License 11 */ 12 13 require ('includes/application_top.php'); 14 require ('includes/classes/http_client.php'); 15 16 // if the customer is not logged on, redirect them to the login page 17 if (!tep_session_is_registered('customer_id')) { 18 $navigation->set_snapshot(); 19 tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); 20 } 21 22 // if there is nothing in the customers cart, redirect them to the shopping cart page 23 if ($cart->count_contents() < 1) { 24 tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); 25 } 26 27 // if no shipping destination address was selected, use the customers own address as default 28 if (!tep_session_is_registered('sendto')) { 29 tep_session_register('sendto'); 30 $sendto = $customer_default_address_id; 31 } else { 32 // verify the selected shipping address 33 $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$sendto . "'"); 34 $check_address = tep_db_fetch_array($check_address_query); 35 36 if ($check_address['total'] != '1') { 37 $sendto = $customer_default_address_id; 38 if (tep_session_is_registered('shipping')) tep_session_unregister('shipping'); 39 } 40 } 41 42 require(DIR_WS_CLASSES . 'order.php'); 43 $order = new order; 44 45 // register a random ID in the session to check throughout the checkout procedure 46 // against alterations in the shopping cart contents 47 if (!tep_session_is_registered('cartID')) tep_session_register('cartID'); 48 $cartID = $cart->cartID; 49 50 // if the order contains only virtual products, forward the customer to the billing page as 51 // a shipping address is not needed 52 if ($order->content_type == 'virtual') { 53 if (!tep_session_is_registered('shipping')) tep_session_register('shipping'); 54 $shipping = false; 55 $sendto = false; 56 tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); 57 } 58 59 $total_weight = $cart->show_weight(); 60 $total_count = $cart->count_contents(); 61 62 // load all enabled shipping modules 63 require (DIR_WS_CLASSES . 'shipping.php'); 64 $shipping_modules = new shipping; 65 66 if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) { 67 $pass = false; 68 69 switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) { 70 case 'national': 71 if ($order->delivery['country_id'] == STORE_COUNTRY) { 72 $pass = true; 73 } 74 break; 75 case 'international': 76 if ($order->delivery['country_id'] != STORE_COUNTRY) { 77 $pass = true; 78 } 79 break; 80 case 'both': 81 $pass = true; 82 break; 83 } 84 85 $free_shipping = false; 86 if ( ($pass == true) && ($order->info['total'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) { 87 $free_shipping = true; 88 89 include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_shipping.php'); 90 } 91 } else { 92 $free_shipping = false; 93 } 94 95 // process the selected shipping method 96 if ( isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') ) { 97 if (!tep_session_is_registered('comments')) tep_session_register('comments'); 98 if (tep_not_null($HTTP_POST_VARS['comments'])) { 99 $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']); 100 } 101 102 if (!tep_session_is_registered('shipping')) tep_session_register('shipping'); 103 104 if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) { 105 if ( (isset($HTTP_POST_VARS['shipping'])) && (strpos($HTTP_POST_VARS['shipping'], '_')) ) { 106 $shipping = $HTTP_POST_VARS['shipping']; 107 108 list($module, $method) = explode('_', $shipping); 109 if ( is_object($$module) || ($shipping == 'free_free') ) { 110 if ($shipping == 'free_free') { 111 $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE; 112 $quote[0]['methods'][0]['cost'] = '0'; 113 } else { 114 $quote = $shipping_modules->quote($method, $module); 115 } 116 if (isset($quote['error'])) { 117 tep_session_unregister('shipping'); 118 } else { 119 if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) { 120 $shipping = array('id' => $shipping, 121 'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'), 122 'cost' => $quote[0]['methods'][0]['cost']); 123 124 tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); 125 } 126 } 127 } else { 128 tep_session_unregister('shipping'); 129 } 130 } 131 } else { 132 $shipping = false; 133 134 tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); 135 } 136 } 137 138 // get all available shipping quotes 139 $quotes = $shipping_modules->quote(); 140 141 // if no shipping method has been selected, automatically select the cheapest method. 142 // if the modules status was changed when none were available, to save on implementing 143 // a javascript force-selection method, also automatically select the cheapest shipping 144 // method if more than one module is now enabled 145 if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest(); 146 147 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_SHIPPING); 148 149 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); 150 $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); 151 ?> 152 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 153 <html <?php echo HTML_PARAMS; ?>> 154 <head> 155 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 156 <title><?php echo TITLE; ?></title> 157 <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> 158 <link rel="stylesheet" type="text/css" href="stylesheet.css"> 159 <script language="javascript"><!-- 160 var selected; 161 162 function selectRowEffect(object, buttonSelect) { 163 if (!selected) { 164 if (document.getElementById) { 165 selected = document.getElementById('defaultSelected'); 166 } else { 167 selected = document.all['defaultSelected']; 168 } 169 } 170 171 if (selected) selected.className = 'moduleRow'; 172 object.className = 'moduleRowSelected'; 173 selected = object; 174 175 // one button is not an array 176 if (document.checkout_address.shipping[0]) { 177 document.checkout_address.shipping[buttonSelect].checked=true; 178 } else { 179 document.checkout_address.shipping.checked=true; 180 } 181 } 182 183 function rowOverEffect(object) { 184 if (object.className == 'moduleRow') object.className = 'moduleRowOver'; 185 } 186 187 function rowOutEffect(object) { 188 if (object.className == 'moduleRowOver') object.className = 'moduleRow'; 189 } 190 //--></script> 191 </head> 192 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> 193 <!-- header //--> 194 <?php require(DIR_WS_INCLUDES . 'header.php'); ?> 195 <!-- header_eof //--> 196 197 <!-- body //--> 198 <table border="0" width="100%" cellspacing="3" cellpadding="3"> 199 <tr> 200 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> 201 <!-- left_navigation //--> 202 <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> 203 <!-- left_navigation_eof //--> 204 </table></td> 205 <!-- body_text //--> 206 <td width="100%" valign="top"><?php echo tep_draw_form('checkout_address', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')) . tep_draw_hidden_field('action', 'process'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> 207 <tr> 208 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 209 <tr> 210 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 211 <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_delivery.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 212 </tr> 213 </table></td> 214 </tr> 215 <tr> 216 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> 217 </tr> 218 <tr> 219 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 220 <tr> 221 <td class="main"><b><?php echo TABLE_HEADING_SHIPPING_ADDRESS; ?></b></td> 222 </tr> 223 </table></td> 224 </tr> 225 <tr> 226 <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> 227 <tr class="infoBoxContents"> 228 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 229 <tr> 230 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 231 <td class="main" width="50%" valign="top"><?php echo TEXT_CHOOSE_SHIPPING_DESTINATION . '<br><br><a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL') . '">' . tep_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>'; ?></td> 232 <td align="right" width="50%" valign="top"><table border="0" cellspacing="0" cellpadding="2"> 233 <tr> 234 <td class="main" align="center" valign="top"><?php echo '<b>' . TITLE_SHIPPING_ADDRESS . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?></td> 235 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 236 <td class="main" valign="top"><?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br>'); ?></td> 237 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 238 </tr> 239 </table></td> 240 </tr> 241 </table></td> 242 </tr> 243 </table></td> 244 </tr> 245 <tr> 246 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> 247 </tr> 248 <?php 249 if (tep_count_shipping_modules() > 0) { 250 ?> 251 <tr> 252 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 253 <tr> 254 <td class="main"><b><?php echo TABLE_HEADING_SHIPPING_METHOD; ?></b></td> 255 </tr> 256 </table></td> 257 </tr> 258 <tr> 259 <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> 260 <tr class="infoBoxContents"> 261 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 262 <?php 263 if (sizeof($quotes) > 1 && sizeof($quotes[0]) > 1) { 264 ?> 265 <tr> 266 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 267 <td class="main" width="50%" valign="top"><?php echo TEXT_CHOOSE_SHIPPING_METHOD; ?></td> 268 <td class="main" width="50%" valign="top" align="right"><?php echo '<b>' . TITLE_PLEASE_SELECT . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_east_south.gif'); ?></td> 269 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 270 </tr> 271 <?php 272 } elseif ($free_shipping == false) { 273 ?> 274 <tr> 275 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 276 <td class="main" width="100%" colspan="2"><?php echo TEXT_ENTER_SHIPPING_INFORMATION; ?></td> 277 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 278 </tr> 279 <?php 280 } 281 282 if ($free_shipping == true) { 283 ?> 284 <tr> 285 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 286 <td colspan="2" width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 287 <tr> 288 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 289 <td class="main" colspan="3"><b><?php echo FREE_SHIPPING_TITLE; ?></b> <?php echo $quotes[$i]['icon']; ?></td> 290 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 291 </tr> 292 <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, 0)"> 293 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 294 <td class="main" width="100%"><?php echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . tep_draw_hidden_field('shipping', 'free_free'); ?></td> 295 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 296 </tr> 297 </table></td> 298 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 299 </tr> 300 <?php 301 } else { 302 $radio_buttons = 0; 303 for ($i=0, $n=sizeof($quotes); $i<$n; $i++) { 304 ?> 305 <tr> 306 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 307 <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 308 <tr> 309 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 310 <td class="main" colspan="3"><b><?php echo $quotes[$i]['module']; ?></b> <?php if (isset($quotes[$i]['icon']) && tep_not_null($quotes[$i]['icon'])) { echo $quotes[$i]['icon']; } ?></td> 311 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 312 </tr> 313 <?php 314 if (isset($quotes[$i]['error'])) { 315 ?> 316 <tr> 317 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 318 <td class="main" colspan="3"><?php echo $quotes[$i]['error']; ?></td> 319 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 320 </tr> 321 <?php 322 } else { 323 for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) { 324 // set the radio button to be checked if it is the method chosen 325 $checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id']) ? true : false); 326 327 if ( ($checked == true) || ($n == 1 && $n2 == 1) ) { 328 echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n"; 329 } else { 330 echo ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n"; 331 } 332 ?> 333 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 334 <td class="main" width="75%"><?php echo $quotes[$i]['methods'][$j]['title']; ?></td> 335 <?php 336 if ( ($n > 1) || ($n2 > 1) ) { 337 ?> 338 <td class="main"><?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); ?></td> 339 <td class="main" align="right"><?php echo tep_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked); ?></td> 340 <?php 341 } else { 342 ?> 343 <td class="main" align="right" colspan="2"><?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])) . tep_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']); ?></td> 344 <?php 345 } 346 ?> 347 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 348 </tr> 349 <?php 350 $radio_buttons++; 351 } 352 } 353 ?> 354 </table></td> 355 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 356 </tr> 357 <?php 358 } 359 } 360 ?> 361 </table></td> 362 </tr> 363 </table></td> 364 </tr> 365 <tr> 366 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> 367 </tr> 368 <?php 369 } 370 ?> 371 <tr> 372 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 373 <tr> 374 <td class="main"><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td> 375 </tr> 376 </table></td> 377 </tr> 378 <tr> 379 <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> 380 <tr class="infoBoxContents"> 381 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 382 <tr> 383 <td><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5'); ?></td> 384 </tr> 385 </table></td> 386 </tr> 387 </table></td> 388 </tr> 389 <tr> 390 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> 391 </tr> 392 <tr> 393 <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> 394 <tr class="infoBoxContents"> 395 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 396 <tr> 397 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 398 <td class="main"><?php echo '<b>' . TITLE_CONTINUE_CHECKOUT_PROCEDURE . '</b><br>' . TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></td> 399 <td class="main" align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> 400 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 401 </tr> 402 </table></td> 403 </tr> 404 </table></td> 405 </tr> 406 <tr> 407 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> 408 </tr> 409 <tr> 410 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 411 <tr> 412 <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 413 <tr> 414 <td width="50%" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'checkout_bullet.gif'); ?></td> 415 <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td> 416 </tr> 417 </table></td> 418 <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td> 419 <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td> 420 <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 421 <tr> 422 <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td> 423 <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td> 424 </tr> 425 </table></td> 426 </tr> 427 <tr> 428 <td align="center" width="25%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_DELIVERY; ?></td> 429 <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_PAYMENT; ?></td> 430 <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td> 431 <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_FINISHED; ?></td> 432 </tr> 433 </table></td> 434 </tr> 435 </table></form></td> 436 <!-- body_text_eof //--> 437 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> 438 <!-- right_navigation //--> 439 <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> 440 <!-- right_navigation_eof //--> 441 </table></td> 442 </tr> 443 </table> 444 <!-- body_eof //--> 445 446 <!-- footer //--> 447 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> 448 <!-- footer_eof //--> 449 <br> 450 </body> 451 </html> 452 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 19:48:25 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |