-
12-12-2019 - |
题
有没有办法阻止所有用户的结算地址修改? 在注册中输入帐单地址后,我不想让用户修改它。 非常感谢。
解决方案
通知
当您考虑Magento如何管理帐单地址时,您要求的是棘手的。 任何地址可以是计费地址。客户可以从系统中的各个点处的菜单组件中选择它(即:结帐,地址簿屏幕)。
即使您在“默认帐单地址”上限制编辑,对于Magento使您的地址簿中的任何地址设置为默认帐单地址,这也为您创造了一些开销。换句话说,客户可以编辑“非计费”地址,然后将其设置为默认帐单地址。写入代码来管理这一点会很麻烦。
,您是否使用了在前端提供地址编辑的任何第三方扩展?这里有很多想法。
解决方案
用免责声明出来,你可以简单地防止通过修改2模板来编辑地址的能力:
# 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.') ?>
...
.
见第9行;在这里,我们只需评论要编辑地址的链接。不安全,但为您提供一个开始的地方。
# 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; ?>
.
在标题下方,我们添加了一些附加逻辑,检查正在编辑的地址是否是默认的账单。如果是这样,它将不会呈现编辑表单,然后显示通用消息。
# 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.') ?>
...
.
# 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; ?>
.