I have used the following code to pass options onto a quote item before adding it to the shopping cart. The options show just fine up through the checkout process, but disappear once the order has been placed. The options do not show up in the confirmation email for the order, on the order review page or in the backend. I need these options to persist for later review.
$cart = Mage::getModel('checkout/cart')
$quote = Mage::getSingleton('checkout/session')->getQuote()
$product = Mage::getModel('catalog/product')->load(7)
$quoteItem=Mage::getModel('sales/quote_item')->setProduct($product)
$a_options = array(
'options1' => array(
'label' => 'Ingredients',
'value' => $recipecontents,
),
'options2' => array(
'label' => 'Crush Grains',
'value' => $crush,
),
);
$quoteItem->addOption(new Varien_Object(
array(
'product' => $quoteItem->getProduct(),
'code' => 'additional_options',
'value' => serialize($a_options)
)
));
$quote->addItem($quoteItem)
$cart->save()
The variables $recipecontents and $crush are defined earlier in the code using data passed from a form.
Everything else works, but as soon as the order has been placed, Magento forgets what the options had been set to. I need these values to persist into the backend in order to fill orders. I am using Community Edition 1.7.0.2.
Does anyone know why these values are being lost and how to prevent it from happening?