I have a one controller class that can work for adding item to cart. My scenario is
My Product has two custom options. One is Child and another one is infant.
I want to add one custom options from these two into my shopping cart. But, I try it many different way. But, I can't see any custom option in checkout page. How can I do that. Here my code sample.
public function indexAction() {
$products = explode(',', $this->getRequest()->getParam('products'));
$cart = Mage::getModel('checkout/cart');
$cart->init();
foreach ($products as $product_id) {
if ($product_id == '') {
continue;
}
$pModel = Mage::getModel('catalog/product')->load($product_id);
$param = array(
'qty' => 2,
'options' => array(
'option_id' => $product_id,
'default_title' => "Ticket for Child or Infant",
'title' => "Child 2 to 12"
)
);
if ($pModel->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL) {
$cart->addProduct($pModel, new Varien_Object($param));
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
}
$cart->save();
$this->_redirect('checkout/cart');
}