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