Reversing Shipping and Billing address

Posts: 6
Joined: 01/14/2008

With most shopping carts the billing address is always asked for first then you are asked if the shipping address. I would like to know what people think and if ubercart could do reverse them?

Thanks

The DotComSecrets.com Dev team

Posts: 112
Joined: 11/10/2007
Bug Finder

This is would be a better solution especially when someone purchases a download product,membership etc. When the customer does a second order with tangle goods, they can just check and the shipping address is the same as billing address and it will solve the issue me a Ryan discussed.

Posts: 4117
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I'm not sure about "most shopping carts," honestly. Maybe some do, but I've used plenty where this isn't the case. (For example, osCommerce has shipping before billing and Amazon.com takes shipping before billing.) The main reason is that for physical goods, we need a shipping address to calculate shipping before getting billing details. And it's good practice to be able to present an order total before asking for billing information... no hidden charges here. Eye-wink

We can tweak the code a little to make it easier to facilitate switching them around (namely that little checkbox for copying addresses), but the default will definitely stay the same.

FYI, you can switch the order in your checkout pane settings menu.

Posts: 112
Joined: 11/10/2007
Bug Finder

I seen the checkout pane settings, but it needs the little box, so it doesn't work correctly when you switch them. It would be a cool addition

Posts: 6
Joined: 01/14/2008

We program a module to change them. Use at your own risk. It would be nice if you could make it so admin have a choice in how it is done.

Thanks

The DotComSecrets.com Dev Team

AttachmentSize
cf_address.zip1.31 KB
Posts: 4117
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Logic has been added to core to support the checkbox in the highest weighted pane. Problem solved. Cool

Posts: 6
Joined: 01/14/2008

Thanks for adding our suggestion.

When checking the copy billing to delivery checkbox, the shipping quote should be triggered. Also, if the copy checkbox is checked and the billing saved addresses is changed, it could also trigger the shipping quote. We had accomplished this by adding the following javascript line:

$('#edit-panes-quotes-quote-button').click();

Thanks,

The DotComSecrets.com Dev Team

Posts: 4117
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

So... where did you guys add that line? Eye-wink

Posts: 6
Joined: 01/14/2008

Oops! It was a change made after we had uploaded our initial module, of course. Shocked

The DotComSecrets.com Dev Team

Posts: 4117
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I gathered that. I'm just curious where in the code you actually put the line so I can do it in core.

Posts: 6
Joined: 01/14/2008

In the uc_cart.js file add the following:

At the end of the uc_cart_copy_address function add:

if (target == 'delivery') {
     $('#edit-panes-quotes-quote-button').click();
  }

At the end of the apply_address function add:

if ((type == 'billing') && copy_box_checked) {
    $('#edit-panes-quotes-quote-button').click();
  }

The DotComSecrets.com Dev Team

Posts: 4117
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I see. Thanks for posting this up. Smiling I may have to get with Lyle and see if he can put a solution into the quote JS itself so we aren't putting quote code in the core cart JS. If we can't work that out, I'll go with the solution here.

Posts: 1968
Joined: 08/07/2007
AdministratoreLiTe!

This is the best I've come up with after wrestling with it for a while.

  $("input[@name*=copy_address]").change(function(){
    triggerQuoteCallback = function(){
      quoteCallback(products);
    };
    if (copy_box_checked == true){
      $("input[@name*=billing_postal_code]").bind('change', triggerQuoteCallback);
      $("select[@name*=billing_address_select]").bind('change', triggerQuoteCallback);
    }
    else{
      $("input[@name*=billing_postal_code]").unbind('change', triggerQuoteCallback);
      $("select[@name*=billing_address_select]").unbind('change', triggerQuoteCallback);
    }
  });

This goes at the end of setQuoteCallbacks(products) in uc_quote.js. The problem with it is that the unbind() calls don't work with the version of jQuery that comes with Drupal 5. The real problem is that you can't really upgrade jQuery without breaking some of the JavaScript functionality of Drupal. There might be a way to do namespace tricks to have two different versions of jQuery, but that's way beyond the scope of Übercart.

Instead, I'm going to try to see if I can prevent the 10 bajillion calls to set_line_item() whenever the address is changed.

Posts: 79
Joined: 08/12/2007
Uber DonorBug FinderInternationalizationizer

btw, the unbind() function works very well after installing the jquery-update module.
[1] http://drupal.org/project/jquery_update

Posts: 1968
Joined: 08/07/2007
AdministratoreLiTe!

well, how about that. I had enabled that module, but I must have forgotten to copy over the jquery file. I think I got distracted by research or something.

I'll include the fix with the other Javascript work I've been doing.