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;
}
}
}
据我所知没有,但你可以看看'customer_entity'表,并检查你是否有空间ID。 – JokiRuiz
我的猜测是他们想测试$ customerID是否为空,并且误将空格 – adrien54
好吧。我认为这是真的。 “customer_entity”没有显示任何空间。谢谢你们两位;) – Amaury