0

The title says it all, is it possible to turn off multiple addresses? Now I can add a different send address and an invoice address, this option breaks a payment option I have since it requires all addresses to be the same.

So my question, is it possible to turn that off? Have the customer only be able to pick 1 address for everything.

1 Answer 1

1

By default, it is not possible in Magento but you can do this programmatically.

To do this, you need to create a custom module. Below are the steps:

Create file app/etc/Stack_Removeshipping.xml and put below code:

<modules>
<Stack_Removeshipping>
<version>0.0.1</version>
</Stack_Removeshipping>
</modules>

Rewrite block class Mage_Checkout_Block_Onepage to change the function to get checkout steps codes.

<global>
<blocks>
<stack_removeshipping>
<class>Stack_Removeshipping_Block</class>
</stack_removeshipping>
<checkout>
<rewrite>
<onepage>Stack_Removeshipping_Block_Checkout_Onepage</onepage>
</rewrite>
</checkout>
</blocks>
</global>

create a file Onepage.php inside folder app/code/local/Stack/Removeshipping/Blocks/Checkout/

class Stack_Removeshipping_Block_Checkout_Onepage extends Mage_Checkout_Block_Onepage
{
protected function _getStepCodes()
{
return array('login', 'billing', 'shipping_method', 'payment', 'review');
}
}

Remove the checkbox and make “use_for_shipping” always true. For this, we need to change the billing.phtml

<frontend>
<layout>
<updates>
<stack_removeshipping>
<file>stack/checkout.xml</file>
</stack_removeshipping>
</updates>
</layout>
</frontend>

Add new layout xml file into your theme

app/design/frontend/[themepackage]/[theme]/layout/[yourlayoutfile].xml

<layout version="0.1.0">
<checkout_onepage_index>
<reference name="checkout.onepage.billing">
<action method="setTemplate"><template>stack/checkout/billing.phtml</template></action>
</reference>
</checkout_onepage_index>
</layout>

Copy billing.phtml from app/design/frontend/base/default/checkout/onepage folder into app/design/frontend/[themepackage]/[theme]/template/stack/checkout folder and find following code:

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

Replace it with:

<li class="control">
<input type="hidden" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1"  />
</li>

Remove shipping address section from right sidebar progress. For this edit the layout xml stack/checkout.xml and your new xml will look like this:

<layout version="0.1.0">
<checkout_onepage_index>
<reference name="checkout.onepage.billing">
<action method="setTemplate"><template>stack/checkout/billing.phtml</template></action>
</reference>
<reference name="checkout.progress">
<remove name="shipping.progress"></remove>
</reference>
</checkout_onepage_index>
</layout>

Rewrite the OnepageController.php. For this first edit add following code inside in config.xml file:

<routers>
<checkout>
<args>
<modules>
<stack_removeshipping before="Mage_Checkout">Stack_Removeshipping</stack_removeshipping>
</modules>
</args>
</checkout>
</routers>

Copy OnepageController.php from app/code/core/Mage/Checkout/controllers folder inside app/code/local/Stack/Removeshipping/controllers folder and except saveBillingAction function delete all other function. Add we just have to comment.

After changes, controller file should look like this:

require_once Mage::getModuleDir('controllers', "Mage_Checkout") . DS . "OnepageController.php";
class Stack_Removeshipping_OnepageController extends Mage_Checkout_OnepageController
{
/**
* Save checkout billing address
*/
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('billing', array());
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
if (isset($data['email'])) {
$data['email'] = trim($data['email']);
}
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);
if (!isset($result['error'])) {
if ($this->getOnepage()->getQuote()->isVirtual()) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
} elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
$result['goto_section'] = 'shipping_method';
$result['update_section'] = array(
'name' => 'shipping-method',
'html' => $this->_getShippingMethodsHtml()
);
/* $result['allow_sections'] = array('shipping');
$result['duplicateBillingInfo'] = 'true';*/
} else {
$result['goto_section'] = 'shipping';
}
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
}

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.