Zen Cart Logo
Forums / Managing Customers and Orders / changing shipping/billing address

changing shipping/billing address

Locked

Views: 4,647

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
15 Aug 2007, 9:29 PM
#1
brycej2 avatar

brycej2

New Zenner

Join Date:
Jan 2007
Posts:
50
Plugin Contributions:
0

changing shipping/billing address

Ok when a user needs to change their shipping or billing address, a form is opened for them to them to do so. The file tpl_modules_checkout_new_address.php contains the form that is used in each case and it decides what to do with the data based on whether it is the billing or shipping address they are changing. Well I need a modified form for shipping, but the original form is fine for billing, so I need, based on whether they are changing the billing or shipping address to give them the right form. I looked at some of the "if" statements in **tpl_modules_checkout_new_address.php **and tried giving them the right form based on this:

if ($_SESSION['billto']) {
   //orignal form
} else if ($_SESSION['shipping']) {
  //modified shipping form
}

It will give them the modified shipping form at first if they try to change shipping address at the very first and the original form if they try to change billing, but after that if they try to change the shipping address again at any point it gives them the original (billing) form, but the shipping address title and headings...how is this possible? If the shipping headings are still making it there, how would the check on the SESSION see it as billing and give them the original (billing) form? Is there a better logic to use to get them the proper form?

hope I wasn't too confusing trying to explain that...

16 Aug 2007, 12:13 AM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,608
Plugin Contributions:
0

Re: changing shipping/billing address

Why do you think you need to do that?

16 Aug 2007, 1:28 PM
#3
brycej2 avatar

brycej2

New Zenner

Join Date:
Jan 2007
Posts:
50
Plugin Contributions:
0

Re: changing shipping/billing address

Kim:

Why do you think you need to do that?

Why do I think I need to do what...I'm not sure what you're asking about.
Look at this picture:

The student information on that form that I have outlined with a red box is what you need to focus on. The fields inside that box are what I need to go on the change shipping address page instead of the original fields, because the items from our store can only be delivered to students on campus. If I merely change the form to contain these modified fields, then the change billing address page will show these student information fields also, which is not what I need...it needs to be the original form. So because of this I need to figure out a way to give them my custom form when they are changing shipping address or the original form if they are changing billing address. The check on the session for either "billto" or "shipping" does not work properly, so I need a better way to figure out which form to display.

16 Aug 2007, 8:57 PM
#4
brycej2 avatar

brycej2

New Zenner

Join Date:
Jan 2007
Posts:
50
Plugin Contributions:
0

Re: changing shipping/billing address

Instead of checking the session like I was above, would doing something like this work better?

switch($addressType) {
        case 'billto':
        //original form and database inserts
        break;
        case 'shipto':
        //modified form and database inserts
        break;
}
16 Aug 2007, 9:13 PM
#5
brycej2 avatar

brycej2

New Zenner

Join Date:
Jan 2007
Posts:
50
Plugin Contributions:
0

Re: changing shipping/billing address

Well the switch statement did the trick. Now I need to figure out why the change shipping address form is not replacing the values in the database.

20 Aug 2007, 7:58 PM
#6
brycej2 avatar

brycej2

New Zenner

Join Date:
Jan 2007
Posts:
50
Plugin Contributions:
0

Re: changing shipping/billing address

Right now when I change my shipping address, it inserts the new address data into the address book table with the proper customer_id but the address_book_id is one more than what it should be, so instead of replacing the new address information in the proper address_book_id row, its getting put into a new row. I need to somehow make the address_book_id be the current one, which I don't understand if I can pull that from the SESSION or what I could do. Here is the code for how I am currently inserting the data:

/**
 * Set some defaults
 */
  $process = false;
  $zone_name = '';
  $entry_state_has_zones = '';
  $error_state_input = false;
  $state = '';
  $zone_id = 0;
  $error = false;

if (isset($_POST['action']) && ($_POST['action'] == 'submit')) {
  // process a new address
  if (zen_not_null($_POST['students_firstname']) && zen_not_null($_POST['students_lastname'])) {
    $process = true;
    $studentfirstname = zen_db_prepare_input($_POST['students_firstname']);
      $studentlastname = zen_db_prepare_input($_POST['students_lastname']);
      $student_email_address = zen_db_prepare_input($_POST['students_email_address']);
      $residencehall = zen_db_prepare_input($_POST['residence_hall']);
      $roomnumber = zen_db_prepare_input($_POST['room_number']);
      $deliverydate = zen_db_prepare_input($_POST['delivery_date']);

    
    if (strlen($studentfirstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
        $error = true;
        $messageStack->add('checkout_address', STUDENT_FIRST_NAME_ERROR);
    }

      if (strlen($studentlastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
        $error = true;
        $messageStack->add('checkout_address', STUDENT_LAST_NAME_ERROR);
      }

      if (isset($_POST['residence_hall']) && $_POST['residence_hall'] == '') {
        $error = true;
        $messageStack->add('checkout_address', RESIDENCE_HALL_ERROR);
      }
  
      if (strlen($roomnumber) < 3) {
        $error = true;
        $messageStack->add('checkout_address', ROOM_NUMBER_ERROR);
      }
  
      if (isset($_POST['delivery_date']) && $_POST['delivery_date'] == '') {
        $error = true;
        $messageStack->add('checkout_address', DELIVERY_DATE_ERROR);
      }


    //if ($error == false) {
     $sql_data_array = array('customers_id' => $_SESSION['customer_id'],
                            'students_firstname' => $studentfirstname, 
                            'students_lastname' => $studentlastname,
                            'students_email_address' => $student_email_address,
                            'delivery_date' => $deliverydate,
                            'residence_hall' => $residencehall,
                            'room_number' => $roomnumber);
      zen_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
      //$db->perform(TABLE_ADDRESS_BOOK, $sql_data_array);
        $_SESSION['sendto'] = $db->Insert_ID();
        $_SESSION['shipping'] = '';
        zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    //}
  } else {
      $_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
      zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  }
}

// This should be last line of the script:
$zco_notifier->notify('NOTIFY_MODULE_END_CHECKOUT_NEW_ADDRESS');

}
21 Aug 2007, 9:14 PM
#7
brycej2 avatar

brycej2

New Zenner

Join Date:
Jan 2007
Posts:
50
Plugin Contributions:
0

Re: changing shipping/billing address

Well could someone at least tell me what this statement (taken from includes/modules/checkout_new_address.php) means/does:

$_SESSION['sendto'] = $_SESSION['customer_default_address_id'];

thanks

27 Aug 2007, 6:42 PM
#8
brycej2 avatar

brycej2

New Zenner

Join Date:
Jan 2007
Posts:
50
Plugin Contributions:
0

Re: changing shipping/billing address

I decided just to UPDATE the address book table, instead of inserting a new one which automatically increments the address book ID. Replacing the previous address in the table with the new one for the same address book ID does what I need it do.