0
votes

I am using Magento Version 1.7.0

I have added shirt size(newly added attributes) drop down box in product detail page.using below code

app\design\frontend\default{mytempalte}\template\catalog\product\view.phtml

 <?php $product = $_product->getAttributeText('size_chart'); ?>    shirt size
<select name="size_chart">
<option value="Select">Select</option>
<?php for($i = 0;$i < count($product);$i++) { ?>
<option value="<?php echo $product[$i]; ?>"><?php echo $product[$i]; ?></option>
<?php } ?>
</select>

customer can able to select the shirt size .After select the shirt size i need to show shirt size in cart and checkout page.

how to pass the shirt size value from product detail to other page?.

Thanks

1
The following will be useful. stackoverflow.com/questions/14876680/…Dushyant Joshi

1 Answers

0
votes

Actually, in cart page you may get cart items in quote object.

$cart = Mage::getModel('checkout/cart')->getQuote();
$items = $cart->getAllVisibleItems();
foreach ($items as $item){
    $options = $item->getProductOptions();
    $superAttributes = $options['info_buyRequest']['super_attribute'];

    if (!!$superAttributes){
        $attributeObjSize = Mage::getModel('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY,'size_chart');
        $attributeObjSizeId = $attributeObjSize->getAttributeId();

        foreach ($superAttributes as $code=>$superAttribute){
            if ($attributeObjSizeId == $code){
                $sizeCode = $superAttribute;
                $sizeLabel = $attributeObjSize->getSource()->getOptionText($sizeCode);
            }
        }
    }
}

The $sizeLabel should be want you would like to have. Hope it works.