checkout - Magento cart items check -


how can check if cart items have custom attribute? , if item/items have custom attribute prints message if 1 of cart item/items doesn't have custom attribute, prints error message in checkout?

please try below code

<?php $productmodel = mage::getmodel('catalog/product'); $cart = mage::getmodel('checkout/cart')->getquote(); $error = ""; foreach ($cart->getallitems() $item) {     $product = $productmodel->load($item->getproduct()->getid());     if($product->getdata('your_attribute_code')){         $message = "your message items have attribute";         $error = 0;     }else{         $message = "your message items have no attributes";         $error = 1;         break;     } } if($error == 1){     mage::getsingleton('core/session')->adderror($message); }else{     mage::getsingleton('core/session')->addsuccess($message);    }  ?> 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -