Skip to main content
deleted 235 characters in body
Source Link
Nickool
  • 1.1k
  • 3
  • 16
  • 38

I want to get the custom customer attribute in the module and see if it is empty or not but this code doesn't work for me, can we get customer attribute in our module? should I use the products to get the customer attribute?

class X_MyCarrier_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface { protected $_code = 'x_mycarrier'; public function collectRates(Mage_Shipping_Model_Rate_Request $request) { if(Mage::getSingleton('customer/session')->isLoggedIn()) { $customerData = Mage::getSingleton('customer/session')->getCustomer(); $cust_id= $customerData->getId(); $_customer = Mage::getModel('customer/customer')->load($cust_id); $_attr=$_customer->getCustomAttribute(); } 

and to check the attribute I used this:

 if(!empty($_attr)&& $_attr=='my_attribute') $result->append($this->_getExpressShippingRate()); 

also because of $request I can have :

 if ($request->getAllItems()) { foreach ($request->getAllItems() as $item) { if ($item->getProduct() 

but I don't know how to get the customer here if I want to get the attribute with this way:

$_product = Mage::getModel('catalog/product'); $attribute = $_product->getResource()->getAttribute('my_attribute'); $at=$attribute->getDefaultValue(); $result->append($at); 

it will not work either

I want to get the custom customer attribute in the module and see if it is empty or not but this code doesn't work for me, can we get customer attribute in our module? should I use the products to get the customer attribute?

class X_MyCarrier_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface { protected $_code = 'x_mycarrier'; public function collectRates(Mage_Shipping_Model_Rate_Request $request) { if(Mage::getSingleton('customer/session')->isLoggedIn()) { $customerData = Mage::getSingleton('customer/session')->getCustomer(); $cust_id= $customerData->getId(); $_customer = Mage::getModel('customer/customer')->load($cust_id); $_attr=$_customer->getCustomAttribute(); } 

and to check the attribute I used this:

 if(!empty($_attr)&& $_attr=='my_attribute') $result->append($this->_getExpressShippingRate()); 

also because of $request I can have :

 if ($request->getAllItems()) { foreach ($request->getAllItems() as $item) { if ($item->getProduct() 

but I don't know how to get the customer here if I want to get the attribute with this way:

$_product = Mage::getModel('catalog/product'); $attribute = $_product->getResource()->getAttribute('my_attribute'); $at=$attribute->getDefaultValue(); $result->append($at); 

it will not work either

I want to get the custom customer attribute in the module and see if it is empty or not but this code doesn't work for me, can we get customer attribute in our module? should I use the products to get the customer attribute?

class X_MyCarrier_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface { protected $_code = 'x_mycarrier'; public function collectRates(Mage_Shipping_Model_Rate_Request $request) { if(Mage::getSingleton('customer/session')->isLoggedIn()) { $customerData = Mage::getSingleton('customer/session')->getCustomer(); $cust_id= $customerData->getId(); $_customer = Mage::getModel('customer/customer')->load($cust_id); $_attr=$_customer->getCustomAttribute(); } 

and to check the attribute I used this:

 if(!empty($_attr)&& $_attr=='my_attribute') $result->append($this->_getExpressShippingRate()); 

also because of $request I can have :

 if ($request->getAllItems()) { foreach ($request->getAllItems() as $item) { if ($item->getProduct() 

but I don't know how to get the customer here if I want to get the attribute with this way:

edited body
Source Link
Nickool
  • 1.1k
  • 3
  • 16
  • 38

I want to get the custom customer attribute in the module and see if it is empty or not but this code doesn't work for me, can we get customer attribute in our module? should I use the products to get the customer attribute?

class X_MyCarrier_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface { protected $_code = 'x_mycarrier'; public function collectRates(Mage_Shipping_Model_Rate_Request $request) { if(Mage::getSingleton('customer/session')->isLoggedIn()) { $customerData = Mage::getSingleton('customer/session')->getCustomer(); $cust_id= $customerData->getId(); $_customer = Mage::getModel('customer/customer')->load($cust_id); $_attr=$_customer->getCustomAttribute(); } 

and to check the attribute I used this:

 if(!empty($_attr)&& $_attr=='cust_account'$_attr=='my_attribute') $result->append($this->_getExpressShippingRate()); 

also because of $request I can have :

 if ($request->getAllItems()) { foreach ($request->getAllItems() as $item) { if ($item->getProduct() 

but I don't know how to get the customer here if I want to get the attribute with this way:

$_product = Mage::getModel('catalog/product'); $attribute = $_product->getResource()->getAttribute('my_attribute'); $at=$attribute->getDefaultValue(); $result->append($at); 

it will not work either

I want to get the custom customer attribute in the module and see if it is empty or not but this code doesn't work for me, can we get customer attribute in our module? should I use the products to get the customer attribute?

class X_MyCarrier_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface { protected $_code = 'x_mycarrier'; public function collectRates(Mage_Shipping_Model_Rate_Request $request) { if(Mage::getSingleton('customer/session')->isLoggedIn()) { $customerData = Mage::getSingleton('customer/session')->getCustomer(); $cust_id= $customerData->getId(); $_customer = Mage::getModel('customer/customer')->load($cust_id); $_attr=$_customer->getCustomAttribute(); } 

and to check the attribute I used this:

 if(!empty($_attr)&& $_attr=='cust_account') $result->append($this->_getExpressShippingRate()); 

also because of $request I can have :

 if ($request->getAllItems()) { foreach ($request->getAllItems() as $item) { if ($item->getProduct() 

but I don't know how to get the customer here if I want to get the attribute with this way:

$_product = Mage::getModel('catalog/product'); $attribute = $_product->getResource()->getAttribute('my_attribute'); $at=$attribute->getDefaultValue(); $result->append($at); 

it will not work either

I want to get the custom customer attribute in the module and see if it is empty or not but this code doesn't work for me, can we get customer attribute in our module? should I use the products to get the customer attribute?

class X_MyCarrier_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface { protected $_code = 'x_mycarrier'; public function collectRates(Mage_Shipping_Model_Rate_Request $request) { if(Mage::getSingleton('customer/session')->isLoggedIn()) { $customerData = Mage::getSingleton('customer/session')->getCustomer(); $cust_id= $customerData->getId(); $_customer = Mage::getModel('customer/customer')->load($cust_id); $_attr=$_customer->getCustomAttribute(); } 

and to check the attribute I used this:

 if(!empty($_attr)&& $_attr=='my_attribute') $result->append($this->_getExpressShippingRate()); 

also because of $request I can have :

 if ($request->getAllItems()) { foreach ($request->getAllItems() as $item) { if ($item->getProduct() 

but I don't know how to get the customer here if I want to get the attribute with this way:

$_product = Mage::getModel('catalog/product'); $attribute = $_product->getResource()->getAttribute('my_attribute'); $at=$attribute->getDefaultValue(); $result->append($at); 

it will not work either

edited tags
Link
benmarks
  • 16.7k
  • 4
  • 42
  • 108
added 284 characters in body
Source Link
Nickool
  • 1.1k
  • 3
  • 16
  • 38
Loading
edited title
Link
Nickool
  • 1.1k
  • 3
  • 16
  • 38
Loading
added 251 characters in body
Source Link
Nickool
  • 1.1k
  • 3
  • 16
  • 38
Loading
Source Link
Nickool
  • 1.1k
  • 3
  • 16
  • 38
Loading