Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 5
Makiing ‘Ship to this address’ the default. 
 
AnneLise
Sr. Member
 
Avatar
Total Posts:  154
Joined:  2008-09-08
Bergen, Norway
 

This works:

To make the same address default go to app/code/core/Mage/Checkout/Block/Onepage/Billing.php (around line 50)

Replace

public function isUseBillingAddressForShipping()
{
        
if (($this->getQuote()->getIsVirtual()) || !$this->getQuote()->getShippingAddress()->getSameAsBilling()) 
        
{
            
return false;
        
}
        
return true;
}

with this:

public function isUseBillingAddressForShipping()
{
        
if (($this->getQuote()->getIsVirtual()) || (!$this->getQuote()->getShippingAddress()->getSameAsBilling()))
        
{
            
return true;
        
else {
            
return false;
        
}
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
jemoon
Sr. Member
 
Avatar
Total Posts:  128
Joined:  2008-09-30
Gdansk, Poland
 

Hi,
just checked on 1.1.8 and seems to work great smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Anjanesh
Sr. Member
 
Avatar
Total Posts:  136
Joined:  2008-03-15
Mumbai, India
 

Is there a way to to have the Shipping Information inside the Billing Information section so that only when the user selects Ship to different Address will the Shipping Information div show up. I want to minimize the number of steps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageParts
Guru
 
Avatar
Total Posts:  415
Joined:  2007-11-18
 

Whats the cause of this problem?
This was quite an annoying issue. See it’s not very clear how everything is saved or read when it comes to the shipping/billing addresses in Magento. See, every time a customer goes through the checkout process a new address quote is created in the sales_flat_quote_address table. Ironically enough this is also the place where the same_as_billing field can be found, which is used to determine whether or not the shipping address is the same as the billing address. And this wouldn’t be known till either A) you select “Ship to this address” and then proceed, or B) your customer selects this address as his/hers primary billing and shipping address from the account menu (after proceeding to the checkout). The later one can’t actually be done before the customer creates a second address by the way. So how do we solve this little pickle?

Solution
We shall compare the selected address choices on their ID. Make the following changes in app/code/core/Mage/Checkout/Block/Onepage/Billing.php

public function isUseBillingAddressForShipping()
    
{
        
if (($this->getQuote()->getIsVirtual())
            || !
$this->getQuote()->getShippingAddress()->getSameAsBilling()) {
            
return false;
        
}
        
return true;
    
}

To

public function isUseBillingAddressForShipping()
    
{
        
if (($this->getQuote()->getIsVirtual())
            || (!
$this->getQuote()->getShippingAddress()->getSameAsBilling() && !$this->billingAddressEqualsShippingAddress())) {
            
return false;
        
}
        
return true;
    
}

Then add the following function before the class ends.

public function billingAddressEqualsShippingAddress()
    
{
        
if($this->getQuote()->getBillingAddress()->getCustomerAddressId() === $this->getQuote()->getShippingAddress()->getCustomerAddressId()) {
            
return true;
        
}
        
return false;
    
}

Thats it! I hope this can help someone else smile

@ Greatmedia, Seems to me that if you wanted to help them you should at the very least have provided information regarding how you quickly search through a folder of documents, and you could just have given them the URL to the file. Everybody doesn’t know all tricks which can be used, it isn’t always obvious you know.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lol
Member
 
Avatar
Total Posts:  68
Joined:  2008-06-26
Plymouth, UK
 

Hi folks,

Very useful thread. Bockbertil’s solution works for me. I’m running Magento 1.2.1.

I had a few problems with some ‘nasty’ invisible characters when I copied and pasted the code above so watch out for that or your php engine will complain!

One other thing for newbies to Magento: if you make this change to Billing.php, be sure to duplicate the original file and place it here:

/app/code/local/Mage/Checkout/Block/Onepage/Billing.php

That way you don’t mess with the Mage folder.

I am learning one small step at a time. smile

As an aside, can someone please explain to me why it is more logical to ship to a different address by default? The Magento folks must have done this for a good reason but I can’t think of one! (Except, maybe, to give a customer something else to do!)

 
Magento Community Magento Community
Magento Community
Magento Community
 
hydra
Guru
 
Avatar
Total Posts:  378
Joined:  2008-08-26
Amsterdam
 
cyfer - 06 August 2008 09:58 AM

Greatmedia: Wow that was a pretty shitty comment. Why not just help out and write which file needs to be edited instead of being a wise guy?
Other users will inevitable also be looking up this thread and finding your answer as the solution is pretty insufficient and ruins the entire flow of this thread.

It’s that you can give someone a fish to eat for a day or you can learn a guy to fish and he can eat everyday.
imo

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageParts
Guru
 
Avatar
Total Posts:  415
Joined:  2007-11-18
 

@Lol glad you enjoy the solution mate wink. Just like you and many others I was to kinda curious about why it made more sense to ship to a different address at first. I came to the conclusion that this must be because some people otherwise would miss this feature. So from a “secure” point of view, this actually makes sense, however this choice should remain with the shop keeper and there should be an option for this somewhere in the system configuration.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MacKniven
Member
 
Total Posts:  51
Joined:  2009-01-09
 

Thanks Bockbertil. Your solution worked great for me…

 
Magento Community Magento Community
Magento Community
Magento Community
 
majacore
Member
 
Avatar
Total Posts:  53
Joined:  2008-12-29
 
laqua - 24 November 2008 09:33 AM

This works:

To make the same address default go to app/code/core/Mage/Checkout/Block/Onepage/Billing.php (around line 50)

Replace....

hacking the core ! not if i can help it, whats wrong with just adjusting the template onepage/billing.phtml ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
lindaw
Sr. Member
 
Total Posts:  201
Joined:  2007-12-25
 

Hi all,

I made this change in order to have the default as “ship to this address” and it works for a guest checkout.

But when you are logged in, both options are blank and you have to select one. Please see the attachment.

Has anyone else experienced this and do you know how to fix it?

Regards,
Linda

Image Attachments
blank.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
nileco
Sr. Member
 
Avatar
Total Posts:  79
Joined:  2008-10-29
Virginia
 
majacore - 16 March 2009 07:58 AM

laqua - 24 November 2008 09:33 AM
This works:

To make the same address default go to app/code/core/Mage/Checkout/Block/Onepage/Billing.php (around line 50)

Replace....

hacking the core ! not if i can help it, whats wrong with just adjusting the template onepage/billing.phtml ?

billing.phtml line 113 change from:

<input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1" <?php if ($this->isUseBillingAddressForShipping()) {?>checked="checked" <?php }?>onclick="$('shipping:same_as_billing').checked = true;" />&nbsp;<label for="billing:use_for_shipping_yes"><?php echo  $this->__('Ship to this address'?></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_no" value="0" <?php if (!$this->isUseBillingAddressForShipping()) {?>checked="checked" <?php }?>onclick="$('shipping:same_as_billing').checked = false;" />&nbsp;<label for="billing:use_for_shipping_no"><?php echo $this->__('Ship to different address'?></label>

to this:

<input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1" checked="checked" <?php if ($this->isUseBillingAddressForShipping()) {?>checked="checked" <?php }?>onclick="$('shipping:same_as_billing').checked = true;" />&nbsp;<label for="billing:use_for_shipping_yes"><?php echo  $this->__('Ship to this address'?></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_no" value="0"  onclick="$('shipping:same_as_billing').checked = false;" type="radio">&nbsp;<label for="billing:use_for_shipping_no"><?php echo $this->__('Ship to different address'?></label>

Seems to work just fine and no core changes.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Gabriel Queiroz
Sr. Member
 
Total Posts:  135
Joined:  2008-05-28
Brasília, Brazil
 

Thanks Nielco.

That worked smoothly… I have also set the class “no-display” on the <p> class right above that line to hide the radio buttons.

Cheers,

 
Magento Community Magento Community
Magento Community
Magento Community
 
PJU751
Jr. Member
 
Total Posts:  10
Joined:  2008-07-12
 
nileco - 03 April 2009 04:23 AM


billing.phtml line 113 change from:

-snip-

to this:

-snip-

Nice, this will override any back end settings though - right? Magento will eventually have an admin setting for this, I take it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nileco
Sr. Member
 
Avatar
Total Posts:  79
Joined:  2008-10-29
Virginia
 

Which browser?  Which Magento version? I just tested and it worked fine through step three and on to checkout.

 
Magento Community Magento Community
Magento Community
Magento Community
 
PJU751
Jr. Member
 
Total Posts:  10
Joined:  2008-07-12
 

My bad, I had changed something else in billing.phtml which caused the problem…

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 5