Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2007
    Posts
    50
    Plugin Contributions
    0

    Default 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:

    PHP Code:
    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...
    Last edited by brycej2; 15 Aug 2007 at 10:32 PM.

  2. #2
    Join Date
    Jun 2003
    Posts
    33,825
    Plugin Contributions
    0

    Default Re: changing shipping/billing address

    Why do you think you need to do that?
    Please do not PM for support issues: a private solution doesn't benefit the community.

    Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

  3. #3
    Join Date
    Jan 2007
    Posts
    50
    Plugin Contributions
    0

    Default Re: changing shipping/billing address

    Quote Originally Posted by Kim View Post
    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.

  4. #4
    Join Date
    Jan 2007
    Posts
    50
    Plugin Contributions
    0

    Default Re: changing shipping/billing address

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

    PHP Code:
    switch($addressType) {
            case 
    'billto':
            
    //original form and database inserts
            
    break;
            case 
    'shipto':
            
    //modified form and database inserts
            
    break;


  5. #5
    Join Date
    Jan 2007
    Posts
    50
    Plugin Contributions
    0

    Default 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.

  6. #6
    Join Date
    Jan 2007
    Posts
    50
    Plugin Contributions
    0

    Default 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:
    PHP Code:
    /**
     * 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');



  7. #7
    Join Date
    Jan 2007
    Posts
    50
    Plugin Contributions
    0

    Default 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:

    PHP Code:
    $_SESSION['sendto'] = $_SESSION['customer_default_address_id']; 
    thanks

  8. #8
    Join Date
    Jan 2007
    Posts
    50
    Plugin Contributions
    0

    Default 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.

 

 

Similar Threads

  1. Email acting strangely after changing contact address
    By Jood in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 13 Jul 2007, 11:48 AM
  2. Tax not changing with Shipping address
    By arpeggio in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 4
    Last Post: 4 Jan 2007, 06:36 AM
  3. saving new shipping/billing address as default..
    By ourcaptain in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 8 Dec 2006, 04:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •