0

I have created a custom customer attribute in Magento ver. 1.9.1.0.

Now during checkout I want to update it's value depending on type of product added in checkout.

Please anybody guide me about, how can I achieve this.

This is only for already registered customers(also logged in at that time) or users who choose to create account during checkout, not for guests ofcourse.

1 Answer 1

0

You will first need to loop through the cart products to check for the existence of the product that is required for the attribute.

Depending on where you want to place the attribute you need to be looking at the template files in YOURTHEME/default/template/checkout/onepage.phtml and YOURTHEME/default/template/checkout/onepage

$cart = Mage::getModel('checkout/cart')->getQuote();
   foreach ($cart->getAllItems() as $item) {
   $productSku = $item->getProduct()->getSku();
   if ($productSku === $myProduct)
   { 
     $showAttribute=true; 
   }
}

if ($showAttribute)
{
 // render custom attribute
}

If the product is present you can show/set the attribute value.

You might find these answers useful

Adding custom attribute to Customer

https://stackoverflow.com/questions/5961290/adding-attributes-to-customer-entity

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.