我在药房工作,我们正在尝试实施该程序,以便当客户签出处方药时,他们必须在文件中注明实际地址。我们拥有标准的Magento结帐控制器,然后,如果他们的购物车中有处方药,他们将在访问该页面后加载自定义控制器。我的问题是如何做到这一点,如果他们没有文件上的物理地址,则该页面将产生错误消息,除非将物理地址添加到其用户帐户,否则将不允许它们继续。
这是我到目前为止在页面控制器中的代码:
public function checkAddressOnFile()
{
return (bool) count(array_filter(Mage::getSingleton('customer/session')->getCustomer()->getAddresses(), function($address) {
return !preg_match("(?i)^\\s*((P(OST)?.?\\s*(O(FF(ICE)?)?)?.?\\s+(B(IN|OX))?)|B(IN|OX)", $address);
}));
Mage::getSingleton('core/session')->addError('Unfortunately we are required to have a physical address on file when shipping any controlled medications. Please note that although we are required to have a physical address on file, we still ship to PO Boxes. We sincerely apologize for the inconvenience.' . $e->getMessage());
}
public function checkAddressOnFile()
{
return (bool) count(array_filter(Mage::getSingleton('customer/session')->getCustomer()->getAddresses(), function($address) {
Mage::getSingleton('core/session')
->addError('Unfortunately we are required to have a physical address on file when shipping any controlled medications. Please note that although we are required to have a physical address on file, we still ship to PO Boxes. We sincerely apologize for the inconvenience.' . $e->getMessage());
return !preg_match("(?i)^\\s*((P(OST)?.?\\s*(O(FF(ICE)?)?)?.?\\s+(B(IN|OX))?)|B(IN|OX)", $address);
}));
}
通知
Mage::getSingleton('core/session')->addNotice('Notice Text...');
取得成功讯息
Mage::getSingleton('core/session')->addSuccess('Success Text...');
对于错误消息
Mage::getSingleton('core/session')->addError('Error Text...');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句