0

My situation is the opposite of this question... and my version is 1.7.0.1

When creating a new order in the back end for phone orders, we're finding that the "Same As Billing Address" tickbox is always checked. My shipping staff are sometimes shipping orders incorrectly due to this because somehow, the shipping address actually isn't the billing address.

Of course, I tried editing app/design/adminhtml/default/default/template/sales/order/create/form/address.phtml on line 67 to remove <?php if($this->getIsAsBilling()): ?>checked<?php endif; ?> from the checkbox, but that is absolutely not the solution. :P Yes, the form then comes up NOT checked, but if you then check it, it stays cleared when it should now be changed.

Which makes me think I am looking at the symptom and the problem is elsewhere.

Help, please, in finding a way to uncheck that box at the beginning of the order?

1
  • You guys are all missing the point. We should not have to hack core files or create custom extensions for something as simple as this. The Magento team should fix this bug. I'm using Magento 2.1.7 and this bug is STILL present! It's extremely frustrating to have bugs as large as this go untouched for all this time. Magento is FULL of bugs and very slow to fix them. I'm never using it for another project again.
    – colefner
    Commented Sep 25, 2017 at 20:46

4 Answers 4

5

Guys this is just horrible solutions. You can’t modify core files (even less copying them to /local) and your problem is related to a backend issue and you end up modifying a file that will also alter the frontend.

If you check this controller : Mage_Adminhtml_Sales_Order_CreateController

You will see there is a function called _processActionData and it sets the setShippingAsBilling to 1.

Just create an extension and add an observer on adminhtml_sales_order_create_process_data to apply the modification you want.

2

Take a look @ app/code/core/Mage/Sales/Model/Quote/Address.php

At Line # 246 in _beforeSave()

if ($this->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING
    && $this->getSameAsBilling() === null
) {
    $this->setSameAsBilling(1);
}

to

if ($this->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING
        && $this->getSameAsBilling() === null
            && $this->getQuote()->getBillingAddress()->getData('customer_address_id') == $this->getQuote()->getShippingAddress()->getData('customer_address_id')
) {
        $this->setSameAsBilling(1);
}

To avoid making change to core you can create a custom module that overwrite Mage_Sales_Model_Quote_Address see http://www.magentocommerce.com/boards/viewthread/53671/ or copy to local folder with the same directory structure

1

Try to change app/code/core/Mage/Sales/Model/Quote/Address.php file. Find function _beforeSave() and review these lines:

 if ($this->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING
            && $this->getSameAsBilling() === null
        ) {
            $this->setSameAsBilling(1);
        }

These lines tell us by default shipping address will be same as billing address for new quote (also same_as_billing column of sales_flat_quote_address table is NULL by default). You should change as:

$this->setSameAsBilling(0);
2
  • 3
    You should never modify a core file.
    – philwinkle
    Commented May 31, 2013 at 17:31
  • 1
    @philwinkle Now that have experience with overrides, I edited the answer to reflect this.
    – Krista K
    Commented Sep 11, 2014 at 18:56
1

Take a look at app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php and find the protected method _initShippingAddressFromOrder(Mage_Sales_Model_Order $order):

$this->getQuote()->getShippingAddress()->setCustomerAddressId('');

To

$orderShippingAddress = $order->getShippingAddress();
$quoteShippingAddress = $this->getQuote()->getShippingAddress()
    ->setCustomerAddressId('')
    ->setSameAsBilling($orderShippingAddress && $orderShippingAddress->getSameAsBilling());

You should never modify a core file. Just create a new module and rewrite the class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.