[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/ -> checkout_payment_address.php (source)

   1  <?php
   2  /*

   3  $Id: checkout_payment_address.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13  // Most of this file is changed or moved to BTS - Basic Template System - format.

  14  // For adding in contribution or modification - parts of this file has been moved to: catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).

  15  //       catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).

  16  // (Sub 'fallback' with your current template to see if there is a template specific file.)

  17  
  18    require ('includes/application_top.php');
  19  
  20  // if the customer is not logged on, redirect them to the login page

  21    if (!tep_session_is_registered('customer_id')) {
  22      $navigation->set_snapshot();
  23      tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  24    }
  25  
  26  // if there is nothing in the customers cart, redirect them to the shopping cart page

  27    if ($cart->count_contents() < 1) {
  28      tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  29    }
  30  
  31  // needs to be included earlier to set the success message in the messageStack

  32    require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PAYMENT_ADDRESS);
  33  
  34    $error = false;
  35    $process = false;
  36    if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'submit')) {
  37  // process a new billing address

  38      if (tep_not_null($HTTP_POST_VARS['firstname']) && tep_not_null($HTTP_POST_VARS['lastname']) && tep_not_null($HTTP_POST_VARS['street_address'])) {
  39        $process = true;
  40  
  41        if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);
  42        if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']);
  43        $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
  44        $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
  45        $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
  46        if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
  47        $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
  48        $city = tep_db_prepare_input($HTTP_POST_VARS['city']);
  49        $country = tep_db_prepare_input($HTTP_POST_VARS['country']);
  50        if (ACCOUNT_STATE == 'true') {
  51          if (isset($HTTP_POST_VARS['zone_id'])) {
  52            $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
  53          } else {
  54            $zone_id = false;
  55          }
  56          $state = tep_db_prepare_input($HTTP_POST_VARS['state']);
  57        }
  58  
  59        if (ACCOUNT_GENDER == 'true') {
  60          if ( ($gender != 'm') && ($gender != 'f') ) {
  61            $error = true;
  62  
  63            $messageStack->add('checkout_address', ENTRY_GENDER_ERROR);
  64          }
  65        }
  66  
  67        if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
  68          $error = true;
  69  
  70          $messageStack->add('checkout_address', ENTRY_FIRST_NAME_ERROR);
  71        }
  72  
  73        if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
  74          $error = true;
  75  
  76          $messageStack->add('checkout_address', ENTRY_LAST_NAME_ERROR);
  77        }
  78  
  79        if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
  80          $error = true;
  81  
  82          $messageStack->add('checkout_address', ENTRY_STREET_ADDRESS_ERROR);
  83        }
  84  
  85        if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
  86          $error = true;
  87  
  88          $messageStack->add('checkout_address', ENTRY_POST_CODE_ERROR);
  89        }
  90  
  91        if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {
  92          $error = true;
  93  
  94          $messageStack->add('checkout_address', ENTRY_CITY_ERROR);
  95        }
  96  
  97        if (ACCOUNT_STATE == 'true') {
  98          $zone_id = 0;
  99          $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "'");
 100          $check = tep_db_fetch_array($check_query);
 101          $entry_state_has_zones = ($check['total'] > 0);
 102          if ($entry_state_has_zones == true) {
 103  // Line changed: Mod RC2A

 104            $zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name = '" . tep_db_input($state) . "' or zone_code = '" . tep_db_input($state) . "')");
 105            if (tep_db_num_rows($zone_query) == 1) {
 106              $zone = tep_db_fetch_array($zone_query);
 107              $zone_id = $zone['zone_id'];
 108            } else {
 109              $error = true;
 110  
 111              $messageStack->add('checkout_address', ENTRY_STATE_ERROR_SELECT);
 112            }
 113          } else {
 114            if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {
 115              $error = true;
 116  
 117              $messageStack->add('checkout_address', ENTRY_STATE_ERROR);
 118            }
 119          }
 120        }
 121  
 122        if ( (is_numeric($country) == false) || ($country < 1) ) {
 123          $error = true;
 124  
 125          $messageStack->add('checkout_address', ENTRY_COUNTRY_ERROR);
 126        }
 127  
 128        if ($error == false) {
 129          $sql_data_array = array('customers_id' => $customer_id,
 130                                  'entry_firstname' => $firstname,
 131                                  'entry_lastname' => $lastname,
 132                                  'entry_street_address' => $street_address,
 133                                  'entry_postcode' => $postcode,
 134                                  'entry_city' => $city,
 135                                  'entry_country_id' => $country);
 136  
 137          if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $gender;
 138          if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company;
 139          if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $suburb;
 140          if (ACCOUNT_STATE == 'true') {
 141            if ($zone_id > 0) {
 142              $sql_data_array['entry_zone_id'] = $zone_id;
 143              $sql_data_array['entry_state'] = '';
 144            } else {
 145              $sql_data_array['entry_zone_id'] = '0';
 146              $sql_data_array['entry_state'] = $state;
 147            }
 148          }
 149  
 150          if (!tep_session_is_registered('billto')) tep_session_register('billto');
 151  
 152          tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
 153  
 154          $billto = tep_db_insert_id();
 155  
 156          if (tep_session_is_registered('payment')) tep_session_unregister('payment');
 157  
 158          tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
 159        }
 160  // process the selected billing destination

 161      } elseif (isset($HTTP_POST_VARS['address'])) {
 162        $reset_payment = false;
 163        if (tep_session_is_registered('billto')) {
 164          if ($billto != $HTTP_POST_VARS['address']) {
 165            if (tep_session_is_registered('payment')) {
 166              $reset_payment = true;
 167            }
 168          }
 169        } else {
 170          tep_session_register('billto');
 171        }
 172  
 173        $billto = $HTTP_POST_VARS['address'];
 174  
 175        $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $customer_id . "' and address_book_id = '" . $billto . "'");
 176        $check_address = tep_db_fetch_array($check_address_query);
 177  
 178        if ($check_address['total'] == '1') {
 179          if ($reset_payment == true) tep_session_unregister('payment');
 180          tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
 181        } else {
 182          tep_session_unregister('billto');
 183        }
 184  // no addresses to select from - customer decided to keep the current assigned address

 185      } else {
 186        if (!tep_session_is_registered('billto')) tep_session_register('billto');
 187        $billto = $customer_default_address_id;
 188  
 189        tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
 190      }
 191    }
 192  // BOF: MOD - Country-State Selector

 193    if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'refresh')) {
 194        if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);
 195        if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']);
 196        $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
 197        $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
 198        $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
 199        if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
 200        $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
 201        $city = tep_db_prepare_input($HTTP_POST_VARS['city']);
 202        $country = tep_db_prepare_input($HTTP_POST_VARS['country']);
 203        if (ACCOUNT_STATE == 'true') {
 204          if (isset($HTTP_POST_VARS['zone_id'])) {
 205            $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
 206          } else {
 207            $zone_id = false;
 208          }
 209          $state = tep_db_prepare_input($HTTP_POST_VARS['state']);
 210        }
 211    } else
 212  // EOF: MOD - Country-State Selector

 213  // if no billing destination address was selected, use their own address as default

 214    if (!tep_session_is_registered('billto')) {
 215      $billto = $customer_default_address_id;
 216    }
 217  // LINE ADDED: MOD - Country-State Selector

 218    if (!isset($country)){$country = DEFAULT_COUNTRY;}
 219  
 220    $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
 221    $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL'));
 222  
 223    $addresses_count = tep_count_customer_address_book_entries();
 224  
 225    $content = CONTENT_CHECKOUT_PAYMENT_ADDRESS;
 226    $javascript = $content . '.js.php';
 227  
 228    include (bts_select('main', $content_template)); // BTSv1.5

 229  
 230    require (DIR_WS_INCLUDES . 'application_bottom.php');
 231  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7