2016-03-23 22 views
1

Bir eczane için çalışıyorum ve bir müşteri reçeteli ilaçları kontrol ettiğinde, dosyada fiziksel bir adresin bulunması için onu uygulamaya çalışıyoruz. Standart Magento çıkış kontrol cihazına sahibiz ve daha sonra kendi kartlarında reçeteli bir ilaçları varsa, bu sayfadan geçtikten sonra özel bir kontrol ünitesi yükler. Sorum şu ki, dosyada fiziksel bir adresi yoksa, sayfa bir hata iletisi üretecek ve kullanıcı hesabına fiziksel bir adres eklemedikçe bunların devam etmesine izin vermeyecek şekilde nasıl yapabilirim? İşte Magento Denetleyici'ye Hata İletisi Ekleme

sayfa için kontrolörün içinde, bugüne kadar ben kodudur: Uyarı

başarı mesajında ​​

Mage::getSingleton('core/session')->addSuccess('Success Text...'); 

için

Mage::getSingleton('core/session')->addNotice('Notice Text...'); 

Satılık

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()); 
    } 

cevap

2
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); 
    })); 

} 

bir hata iletisi

Mage::getSingleton('core/session')->addError('Error Text...'); 
+0

Bu çalışmadı. – djames

+0

Özür dilerim cevabım size yardımcı olmadı ama tam olarak çözüm vermeye çalışacağım –

+0

Cevabımı güncelledim lütfen –