19 replies [Last post]
backdrifting's picture
Offline
Joined: 10/03/2008
Juice: 373
Was this information Helpful?

In the Checkout form of our Ubercart cart process, is it possible to show a site customer only the Delivery Information pane, or for that matter only the Billing Info pane at Checkout, but not both? I'd like to ask the customer for this address info once in the checkout process but not force the user to have to enter it twice (even with the "My Billing info is the same as my ..." checkbox controller.

... or are both panes necessary to the Ubercart checkout process. Would there be anything detrimental (from a best practice workflow) to disabling one of these panes?

Thanks in advance for any suggestions.

-backdrifting

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4111
Re: Delivery and Billing information at Checkout

You can disable any checkout panes you wish:

/admin/store/settings/checkout/edit/panes

Just make sure your customers are aware that you can only ship to billing addresses and I think you'll be fine.

--
Help directly fund development: Donate via PayPal!

backdrifting's picture
Offline
Joined: 10/03/2008
Juice: 373
Disabling the shipping pane ...

Sweet! Yes, that's exactly what I'd like to do. Does this have any negative effect on our Ubercart integration with the FedEx API module (http://www.ubercart.org/contrib/2106)? If we disable the shipping pane and only show customers the Billing pane, will this cause issues for the shipping quote modules and/or shipping options (FedEx and USPS) that we're using? Do the shipping modules rely on the shipping pane from a functional perspective or can they use the billing address info as their shipping info?

Thanks!

-backdrifting

backdrifting's picture
Offline
Joined: 10/03/2008
Juice: 373
Re: Re: Delivery and Billing information at Checkout

Yes, as I suspected the Delivery Info pane looks like it's tied directly to the FedEx quote module. If I disable that pane, the FedEx quotes don't appear.

I'm assuming here that if I disable the Billing address pane, then the billing address verification to the credit card # won't work either.

So it doesn't look like you can disable either out-of-the-box and still get the shipping and billing functionality.

-backdrifting

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4111
Re: Re: Re: Delivery and Billing information at Checkout

I thought that might be a problem.

I think this would be a good candidate for a Contrib to get rolled into core. Perhaps an option in the checkout panes admin to allow you to use one to override the other. It wouldn't be hard at all to use the values from one form to set the values for the other (form_set_value)... that's how I'd probably go about it.

I'm actually kind of surprised that the billing and shipping panes are not "required" panes, since they seem to have functionality tethered to them.

--
Help directly fund development: Donate via PayPal!

backdrifting's picture
Offline
Joined: 10/03/2008
Juice: 373
Contrib to core sounds good ...

Yes, I'm definitely interested in helping to make this happen - has anyone started work on this development that you're aware of? Or would I/we be building this functionality from scratch? I'll take a look at the code this week as I'm working on a project now where I have this in the spec as a requirement. As you note, I'll look at the form_set_value and see what's going on there.

Any other suggestions?

-backdrifting

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4111
Re: Contrib to core sounds good ...

Yeah you'd be doing this from scratch. Seems rather easy to do a helper module that gives you the option and then intercepts the form as I mentioned.

--
Help directly fund development: Donate via PayPal!

Rainman's picture
Offline
Joined: 08/26/2009
Juice: 24
Re: Contrib to core sounds good ...

Has anyone gotten anywhere with this one? I am finding lost conversions due to mis-typed address in billing (when it appears they got it right the first time in shipping!) just seems the flow should be to assume they are the same initially, then give the option to change if needed. for that matter really, seems billing should be first and then checkbox should be for shipping same/different (default same).

if no work has been done a nudge in the right direction please? willing to do the work, just no idea where to start.

Rainman's picture
Offline
Joined: 08/26/2009
Juice: 24
Re: Re: Contrib to core sounds good ...

well I did find the not obvious that if you switch the order of the panes (billing before shipping) then the message changes to "My delivery information is the same as my billing information." so that helps.. the user is more likely to type in the correct information the first time.

still, the original issue.. I did some poking around in the code and see that the second form is filled by an onclick action. maybe not so simple to code around, at least not for me so far.

grobot's picture
Offline
Joined: 04/12/2008
Juice: 289
Re: Re: Re: Contrib to core sounds good ...

In your custom module -

<?php
/* in hook_menu() (D5) or hook_init() (D6) */
if ( arg(0) == 'cart' && arg(1) == 'checkout' ) {
 
drupal_add_js('path/to/my/custom.js');
}

?>

And in path/to/my/custom.js -

$(document).ready( function() {
  $('#edit-panes-billing-copy-address').attr('checked',true);
  uc_cart_copy_address(true,'delivery','billing');
});

This works for me, except in IE6. (I'd add a picture of Nelson Muntz saying "Ha-Ha" here if I could.)

Giant Robot - for campaign, charity, ngo & online store solutions - www.giantrobot.co.nz

backdrifting's picture
Offline
Joined: 10/03/2008
Juice: 373
Trick the shipping quote modules?

So I guess the next question is ... can you trick the FedEx module and/or any of the shipping quote modules into using the Billing Address info as the shipping info as well? So you can enable only the billing address but this will then work for the shipping quote fulfillment?

-backdrifting

ravasolutions.com's picture
Offline
Joined: 11/19/2009
Juice: 24
Possible solution to your problem

So you want "My billing information is the same as my delivery information." to be checked by default?
And address copied over without making user click on that evil check box? Try this hack.

Edit uc_cart_checkout_pane.inc

function uc_checkout_pane_delivery($op, &$arg1, $arg2) {

...
          '#attributes' => array('onclick' => "uc_cart_copy_address(this.checked, 'billing', 'delivery');",
				 'checked' => "yes"),
        );

and

 
function uc_checkout_pane_billing($op, &$arg1, $arg2) {

...
          '#attributes' => array('onclick' => "uc_cart_copy_address(this.checked, 'delivery', 'billing');",
				 'checked' => "yes"),
        );

Its all nice and pretty now but what will take care of copying that address from the delivery to billing?
In case you haven't noticed the point of clicking the check box is just that - call uc_cart_copy_address()
which takes care of copying. Lets see if we can hijack another click here. Inside the script.js add

$(document).ready(function() {
	$("#edit-continue").click(function(){
			if ($('#edit-panes-billing-copy-address').is(':checked')){
				uc_cart_copy_address(true, 'delivery', 'billing');
			}
			if ($('#edit-panes-delivery-copy-address').is(':checked')){ 
				uc_cart_copy_address(true, 'billing', 'delivery');
			}
	});
});

What just happened!? We told the "Review Order" button to copy the address before submitting the form.
That's it. At least for that part. Now lets finish the job and make it all pretty. Since we're saying
our address is the same there's no point to display the empty form underneath confusing the customer

Back to script.js right underneath the closing tag for $(document).ready(); Insert the following code

$(window).bind('load', function () {
	if ($('#edit-panes-billing-copy-address').is(':checked')){
		$('#billing-pane div.address-pane-table').slideUp();
	}
	if ($('#edit-panes-delivery-copy-address').is(':checked')){
		$('#delivery-pane div.address-pane-table').slideUp();
	}
});

And if you haven't figured it out on your own, It'll close the second pane (billing/delivery - depends on
the type of check box you have).

dzieyzone's picture
Offline
Joined: 01/13/2010
Juice: 24
Why not just do this: Create

Why not just do this:
Create a custom module for your site. include the following line in your module_name_form_alter(&$form, $form_state, $form_id)

if ($form_id == 'uc_cart_checkout_form') {
if (empty($form['pane']['billing']['billing_first_name']['#default_value'])){
drupal_add_js(drupal_get_path('module','module_name').'/billing.trigger.js');
}
}

then create a billing.trigger.js inside your custom module containing the code below:

$(document).ready(function(){
$('#edit-panes-billing-copy-address').trigger('click');
});
mandclu's picture
Offline
Bug Finder
Joined: 11/19/2007
Juice: 78
Re: Why not just do this: Create

If all you need to do is add three lines of javascript, why not just add them to your theme's script.js?

mandclu's picture
Offline
Bug Finder
Joined: 11/19/2007
Juice: 78
Block Solution

I got thinking about it and realized that in my particular case, the theme is shared between two subdomains and I didn't really want that to fire on every page of both sites.

I decided to put the information in a block instead, and set the block to only appear on cart/checkout

Here's the code I put in the block (don't forget to set the filter to PHP):

<?php
drupal_add_js
("
$(document).ready(function(){
  if (!$('edit-panes-billing-billing-first-name').val()) {
    $('#edit-panes-billing-copy-address').trigger('click');
  }
});
"
, 'inline', 'header', FALSE, TRUE, FALSE);
?>

I'll admit that it is a little hackish to have JS wrapped in PHP in a block, but it's a workable solution to an issue that really should be address in Ubercart core.

PlanetPHP's picture
Offline
Joined: 08/18/2010
Juice: 42
Re: Block Solution

Will this not work if the address was altered as in the comment above http://www.ubercart.org/forum/support/6830/delivery_and_billing_informat... the data is copied across in the order submit if the checkbox is ticked.

mandclu's picture
Offline
Bug Finder
Joined: 11/19/2007
Juice: 78
Re: Re: Block Solution

That looks like it would work too, but IMHO it's more work to achieve the same thing. Two ways to do the same thing. Has there been any discussion about allowing Ubercart to do this without these kinds of hacks?

chris80's picture
Offline
Joined: 02/25/2009
Juice: 36
Re: Block Solution

That works just fine, but there is a small mistake inside.

billing should be delivery:

<?php
drupal_add_js
("
$(document).ready(function(){
  if (!$('edit-panes-billing-billing-first-name').val()) {
    $('#edit-panes-delivery-copy-address').trigger('click');
  }
});
"
, 'inline', 'header', FALSE, TRUE, FALSE);
?>

I recon, it would be another nice to have, to fill out the address automatically when the customer orders the second time.

edit-panes-billing-billing-address-select
is the dropdown. And onchange contains this:
apply_address('billing', this.value);

Problem now is: this.value contains kind of an array:
{ "first_name": "Chris", "last_name": "Test", "phone": "", "company": "", "street1": "Teststr. 17", "street2": "", "city": "Frankfurt", "zone": "0", "postal_code": "60311", "country": "276" }
Would it be easier to prepopulate the fields via PHP?
Or is it possible to invoke this method somehow?

Best regards
Chris

MikeNGarrett's picture
Offline
Joined: 04/28/2011
Juice: 6
Re: Delivery and Billing information at Checkout

The Checkout Tweaks module seems to have solved this issue.

http://drupal.org/project/uc_checkout_tweaks

@MikeNGarrett

shotokai's picture
Offline
Joined: 12/02/2010
Juice: 17
Re: Re: Delivery and Billing information at Checkout

I'm using Checkout Tweaks - and its great, but I don't believe it solves the issue of only showing a single address entry form on its own. When you disable one of the panes it produces errors. However, with a teeny bit of CSS, you can make the pane you want to exclude go away and still have checkout tweaks work as intended:

#delivery-pane{ visibility: hidden; display: none;}
or

#billing-pane{ visibility: hidden; display: none;}