How to get Custom Options Programmatically in Magento

前端 未结 7 2192
天涯浪人
天涯浪人 2020-12-09 05:20

I have a couple products at checkout that I need to be able to get all of the custom options that are selected for them through code.

Any help is much appreciated! <

相关标签:
7条回答
  • 2020-12-09 05:58
        $quote=$observer->getEvent()->getQuote();
        $quoteid=$quote->getId();
        $session= Mage::getSingleton('checkout/session');
        $getotal = Mage::helper('checkout')->getQuote()->getGrandTotal();
    
        foreach($session->getQuote()->getAllItems() as $item)
            {
    
             $sellcheck = Mage::getModel('catalog/product')->load($item->getProduct()->getId())->getissellbool();
             $options = Mage::getModel('catalog/product')->load($item->getProduct()->getId())->getProductOptionsCollection();
             foreach ($options as $o) 
                 { 
                    $title = $o->getTitle();
                    $values = $o->getValues();
                    foreach($values as $v)
                      {
                         $mydata = $v->getPrice();
                         echo 'options price: ' . $mydata;                      
                            }
    
                   } 
    
              }
    

    To access product custom options at the shopping cart you can utilise this code.

    0 讨论(0)
提交回复
热议问题