helsingius Posted June 27, 2013 Share Posted June 27, 2013 My code <?php $radio_buttons = 0; $addresses_query = tep_db_query("select address_book_id, entry_firstname as firstname, 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 = '" . (int)$customer_id . "'"); while ($addresses = tep_db_fetch_array($addresses_query)) { $format_id = tep_get_address_format_id($addresses['country_id']); ?> does not work well <?php $radio_buttons = 0; $addresses_query = tep_db_query("select address_book_id, entry_firstname as firstname, entry_postcode as postcode, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "'"); while ($addresses = tep_db_fetch_array($addresses_query)) { $format_id = tep_get_address_format_id($addresses['country_id']); ?> I must do :mellow: <?php require('includes/application_top.php'); // if the customer is not logged on, redirect them to the login page if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } // if there is nothing in the customers cart, redirect them to the shopping cart page if ($cart->count_contents() < 1) { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); } // needs to be included earlier to set the success message in the messageStack require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_SHIPPING_ADDRESS); require(DIR_WS_CLASSES . 'order.php'); $order = new order; // 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') { if (!tep_session_is_registered('shipping')) tep_session_register('shipping'); $shipping = false; if (!tep_session_is_registered('sendto')) tep_session_register('sendto'); $sendto = false; tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); } $error = false; $process = false; if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'submit')) { // process a new shipping address if (tep_not_null($HTTP_POST_VARS['firstname']) && tep_not_null($HTTP_POST_VARS['street_address'])) { $process = true; if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']); if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']); $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']); $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']); if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']); $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']); $city = tep_db_prepare_input($HTTP_POST_VARS['city']); $country = tep_db_prepare_input($HTTP_POST_VARS['country']); if (ACCOUNT_STATE == 'true') { if (isset($HTTP_POST_VARS['zone_id'])) { $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']); } else { $zone_id = false; } $state = tep_db_prepare_input($HTTP_POST_VARS['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($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 = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "'"); $check = tep_db_fetch_array($check_query); $entry_state_has_zones = ($check['total'] > 0); if ($entry_state_has_zones == true) { $zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name like '" . tep_db_input($state) . "%' or zone_code like '%" . tep_db_input($state) . "%')"); if (tep_db_num_rows($zone_query) == 1) { $zone = tep_db_fetch_array($zone_query); $zone_id = $zone['zone_id']; } else { $error = true; $messageStack->add('checkout_address', 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' => $customer_id, 'entry_firstname' => $firstname, '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; } } if (!tep_session_is_registered('sendto')) tep_session_register('sendto'); tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array); $sendto = tep_db_insert_id(); if (tep_session_is_registered('shipping')) tep_session_unregister('shipping'); tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } // process the selected shipping destination } elseif (isset($HTTP_POST_VARS['address'])) { $reset_shipping = false; if (tep_session_is_registered('sendto')) { if ($sendto != $HTTP_POST_VARS['address']) { if (tep_session_is_registered('shipping')) { $reset_shipping = true; } } } else { tep_session_register('sendto'); } $sendto = $HTTP_POST_VARS['address']; $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 . "'"); $check_address = tep_db_fetch_array($check_address_query); if ($check_address['total'] == '1') { if ($reset_shipping == true) tep_session_unregister('shipping'); tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } else { tep_session_unregister('sendto'); } } else { if (!tep_session_is_registered('sendto')) tep_session_register('sendto'); $sendto = $customer_default_address_id; tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } } // if no shipping destination address was selected, use their own address as default if (!tep_session_is_registered('sendto')) { $sendto = $customer_default_address_id; } $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL')); $addresses_count = tep_count_customer_address_book_entries(); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <script language="javascript"><!-- var selected; function selectRowEffect(object, buttonselect) { if (!selected) { if (document.getElementById) { selected = document.getElementById('defaultSelected'); } else { selected = document.all['defaultSelected']; } } if (selected) selected.className = 'moduleRow'; object.className = 'moduleRowSelected'; selected = object; // one button is not an array if (document.checkout_address.address[0]) { document.checkout_address.address[buttonselect].checked=true; } else { document.checkout_address.address.checked=true; } } function rowOverEffect(object) { if (object.className == 'moduleRow') object.className = 'moduleRowOver'; } function rowOutEffect(object) { if (object.className == 'moduleRowOver') object.className = 'moduleRow'; } function check_form_optional(form_name) { var form = form_name; var firstname = form.elements['firstname'].value; var street_address = form.elements['street_address'].value; if (firstname == '' && street_address == '') { return true; } else { return check_form(form_name); } } //--></script> <?php require(DIR_WS_INCLUDES . 'form_check.js.php'); ?> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.