Admin order create: Shipping same as Billing always checked: can I clear that?
-
16-10-2019 - |
Question
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?
Solution
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.
OTHER TIPS
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
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);
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.