2015-08-19 51 views
2

我目前正在檢查一個Magento擴展,我對一段代碼有一點疑問。我想請你解釋一下。我明白這一切,但不是這一個:Magento代碼需要精確

$customerID == " " 

有沒有這樣的情況下,Magento有這樣的客戶id(空間?)? 非常感謝您的回覆! 這裏是整個功能。

public function isAvailable(Varien_Event_Observer $observer) 
{ 

    $event   = $observer->getEvent(); 
    $method   = $event->getMethodInstance(); //$method return the payment method 
    $result   = $event->getResult();   //$result return true if method is active 
    $quote   = $event->getQuote();   //$quote return var from cart 
    if($method->getCode() == 'custompayment'){ 
     //$customerGroup  = $quote->getCustomerGroupId(); 
     // $customerGroup=""; 
     // $customerID=""; 
     $login = Mage::getSingleton('customer/session')->isLoggedIn(); //Check if User is Logged In 
    if($login) 
    { 
     $customerGroup = Mage::getSingleton('customer/session')->getCustomerGroupId(); //Get Customers Group ID 
     $customerID = Mage::getSingleton('customer/session')->getCustomerId(); //Get Customers ID 

    } 
     $selectedCustomerGroups = Mage::getStoreConfig('payment/custompayment/specificcustomers'); 
     $selectedCustomerGroupsArray = explode(",", $selectedCustomerGroups); 
      if($selectedCustomerGroups != "" || $customerID == " "){ 
       if(!in_array($customerGroup, $selectedCustomerGroupsArray)) { 
          $result->isAvailable = false; 
        } 

      } 
      else{ 
       if($result->isAvailable==1){ 
        $result->isAvailable = true; 
       } 
      } 

    } 
+0

據我所知沒有,但你可以看看'customer_entity'表,並檢查你是否有空間ID。 – JokiRuiz

+1

我的猜測是他們想測試$ customerID是否爲空,並且誤將空格 – adrien54

+0

好吧。我認爲這是真的。 「customer_entity」沒有顯示任何空間。謝謝你們兩位;) – Amaury

回答

0

通過adrien54和JokiRuiz回答。