is there a way to prevent Billing Address modification by all users? After entering billing address in registration i don't want to let users modificate it. Thank you very much.
1 Answer
Notice
What you're asking for becomes tricky when you consider how Magento manages the billing address. Any address can be a billing address. A customer can simply select it from a menu component at various points in the system (ie: checkout, address book screen).
Even if you restrict editing on the "default billing address," this too creates some overhead for you, given that Magento enables you to set any address in your address book as the default billing address. In other words, a customer could edit a "non-billing" address, then set it as the default billing address. It would be cumbersome for you to write code to manage this.
And are you using any third-party extensions which provide address editing on the front-end? There's a lot to think about here.
A Solution
With the disclaimer out of the way, you can simply prevent the ability to edit an address by modifying 2 templates:
# File: app/design/frontend/[package]/[theme]/template/customer/address/book.phtml
...
<h2><?php echo $this->__('Default Addresses') ?></h2>
<ol>
<?php if($_pAddsses = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling()): ?>
<li class="info-box">
<div class="title-wrap">
<h3><?php echo $this->__('Default Billing Address') ?></h3>
<?php /*<a href="<?php echo $this->getAddressEditUrl(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>"><?php echo $this->__('Change Billing Address') ?></a>*/ ?>
</div>
<address class="box-content">
<?php echo $this->getAddressHtml(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>
</address>
</li>
<?php else: ?>
<li class="info-box">
<h3><?php echo $this->__('Default Billing Address') ?></h3>
<?php echo $this->__('You have no default billing address in your address book.') ?>
...
See line 9; here we simply comment out the link to edit the address. Not secure, but gives you a place to start.
# File: app/design/frontend/[package]/[theme]/template/customer/address/edit.phtml
...
<?php
/**
* Edit customer address template
*
* @see Mage_Customer_Block_Address_Edit
*/
?>
<?php if($this->getTitle()): ?>
<div class="page-title">
<h1><?php echo $this->getTitle() ?></h1>
</div>
<?php endif; ?>
<?php if ($address->getId() === Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling()) :?>
<p><?php echo $this->__('Sorry, but you cannot modify this address.'); ?></p>
<?php else : ?>
...
<?php endif; ?>
Below the title, we add some additional logic that checks if the address being edited is the default billing. If so, it will not render the edit form and instead display a generic message.
-
That's what i did before your answer, same solution that urgency suggested! :) Anyways, thank you very much. Commented Dec 21, 2014 at 11:30
-
The real problem however is in Checkout. Here Magento suggests using the shipping address as billing address, eliminating all relevancies of the billing address. Customers even get the possibility of creating a new billing address.– leedchCommented Feb 6, 2017 at 15:17