[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
1 <?php 2 /** 3 * Checkout Shipping Page 4 * 5 * @package page 6 * @copyright Copyright 2003-2006 Zen Cart Development Team 7 * @copyright Portions Copyright 2003 osCommerce 8 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 9 * @version $Id: header_php.php 5380 2006-12-24 17:50:00Z drbyte $ 10 */ 11 // This should be first line of the script: 12 $zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_SHIPPING'); 13 14 require_once(DIR_WS_CLASSES . 'http_client.php'); 15 16 // if there is nothing in the customers cart, redirect them to the shopping cart page 17 if ($_SESSION['cart']->count_contents() <= 0) { 18 zen_redirect(zen_href_link(FILENAME_TIME_OUT)); 19 } 20 21 // if the customer is not logged on, redirect them to the login page 22 if (!$_SESSION['customer_id']) { 23 $_SESSION['navigation']->set_snapshot(); 24 zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL')); 25 } else { 26 // validate customer 27 if (zen_get_customer_validate_session($_SESSION['customer_id']) == false) { 28 $_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_SHIPPING)); 29 zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL')); 30 } 31 } 32 33 // Validate Cart for checkout 34 $_SESSION['valid_to_checkout'] = true; 35 $_SESSION['cart']->get_products(true); 36 if ($_SESSION['valid_to_checkout'] == false) { 37 $messageStack->add('header', ERROR_CART_UPDATE, 'error'); 38 zen_redirect(zen_href_link(FILENAME_SHOPPING_CART)); 39 } 40 41 // Stock Check 42 if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) { 43 $products = $_SESSION['cart']->get_products(); 44 for ($i=0, $n=sizeof($products); $i<$n; $i++) { 45 if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) { 46 zen_redirect(zen_href_link(FILENAME_SHOPPING_CART)); 47 break; 48 } 49 } 50 } 51 // if no shipping destination address was selected, use the customers own address as default 52 if (!$_SESSION['sendto']) { 53 $_SESSION['sendto'] = $_SESSION['customer_default_address_id']; 54 } else { 55 // verify the selected shipping address 56 $check_address_query = "SELECT count(*) AS total 57 FROM " . TABLE_ADDRESS_BOOK . " 58 WHERE customers_id = :customersID 59 AND address_book_id = :addressBookID"; 60 61 $check_address_query = $db->bindVars($check_address_query, ':customersID', $_SESSION['customer_id'], 'integer'); 62 $check_address_query = $db->bindVars($check_address_query, ':addressBookID', $_SESSION['sendto'], 'integer'); 63 $check_address = $db->Execute($check_address_query); 64 65 if ($check_address->fields['total'] != '1') { 66 $_SESSION['sendto'] = $_SESSION['customer_default_address_id']; 67 $_SESSION['shipping'] = ''; 68 } 69 } 70 71 require(DIR_WS_CLASSES . 'order.php'); 72 $order = new order; 73 74 // register a random ID in the session to check throughout the checkout procedure 75 // against alterations in the shopping cart contents 76 $_SESSION['cartID'] = $_SESSION['cart']->cartID; 77 78 // if the order contains only virtual products, forward the customer to the billing page as 79 // a shipping address is not needed 80 if ($order->content_type == 'virtual') { 81 $_SESSION['shipping'] = 'free_free'; 82 $_SESSION['shipping']['title'] = 'free_free'; 83 $_SESSION['sendto'] = false; 84 zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); 85 } 86 87 $total_weight = $_SESSION['cart']->show_weight(); 88 $total_count = $_SESSION['cart']->count_contents(); 89 90 // load all enabled shipping modules 91 require(DIR_WS_CLASSES . 'shipping.php'); 92 $shipping_modules = new shipping; 93 94 if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) { 95 $pass = false; 96 97 switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) { 98 case 'national': 99 if ($order->delivery['country_id'] == STORE_COUNTRY) { 100 $pass = true; 101 } 102 break; 103 case 'international': 104 if ($order->delivery['country_id'] != STORE_COUNTRY) { 105 $pass = true; 106 } 107 break; 108 case 'both': 109 $pass = true; 110 break; 111 } 112 113 $free_shipping = false; 114 if ( ($pass == true) && ($_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) { 115 $free_shipping = true; 116 } 117 } else { 118 $free_shipping = false; 119 } 120 121 require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php')); 122 123 if (isset($_SESSION['comments'])) { 124 $comments = $_SESSION['comments']; 125 } 126 127 128 // process the selected shipping method 129 if ( isset($_POST['action']) && ($_POST['action'] == 'process') ) { 130 if (zen_not_null($_POST['comments'])) { 131 $_SESSION['comments'] = zen_db_prepare_input($_POST['comments']); 132 } 133 $comments = $_SESSION['comments']; 134 135 if ( (zen_count_shipping_modules() > 0) || ($free_shipping == true) ) { 136 if ( (isset($_POST['shipping'])) && (strpos($_POST['shipping'], '_')) ) { 137 $_SESSION['shipping'] = $_POST['shipping']; 138 139 list($module, $method) = explode('_', $_SESSION['shipping']); 140 if ( is_object($$module) || ($_SESSION['shipping'] == 'free_free') ) { 141 if ($_SESSION['shipping'] == 'free_free') { 142 $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE; 143 $quote[0]['methods'][0]['cost'] = '0'; 144 } else { 145 $quote = $shipping_modules->quote($method, $module); 146 } 147 if (isset($quote['error'])) { 148 $_SESSION['shipping'] = ''; 149 } else { 150 if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) { 151 $_SESSION['shipping'] = array('id' => $_SESSION['shipping'], 152 'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'), 153 'cost' => $quote[0]['methods'][0]['cost']); 154 155 zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); 156 } 157 } 158 } else { 159 $_SESSION['shipping'] = false; 160 } 161 } 162 } else { 163 $_SESSION['shipping'] = false; 164 165 zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); 166 } 167 } 168 169 // get all available shipping quotes 170 $quotes = $shipping_modules->quote(); 171 172 // if no shipping method has been selected, automatically select the cheapest method. 173 // if the modules status was changed when none were available, to save on implementing 174 // a javascript force-selection method, also automatically select the cheapest shipping 175 // method if more than one module is now enabled 176 if ( !$_SESSION['shipping'] || ( $_SESSION['shipping'] && ($_SESSION['shipping'] == false) && (zen_count_shipping_modules() > 1) ) ) $_SESSION['shipping'] = $shipping_modules->cheapest(); 177 178 179 // Should address-edit button be offered? 180 $displayAddressEdit = (MAX_ADDRESS_BOOK_ENTRIES >= 2); 181 182 // if shipping-edit button should be overridden, do so 183 $editShippingButtonLink = zen_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL'); 184 if (isset($_SESSION['payment']) && method_exists($$_SESSION['payment'], 'alterShippingEditButton')) { 185 $theLink = $$_SESSION['payment']->alterShippingEditButton(); 186 if ($theLink) { 187 $editShippingButtonLink = $theLink; 188 $displayAddressEdit = true; 189 } 190 } 191 192 $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); 193 $breadcrumb->add(NAVBAR_TITLE_2); 194 195 // This should be last line of the script: 196 $zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_SHIPPING'); 197 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |