How To Add Magento Bundle To Current Cart Programmatically

Currently, I am building my own extension, I would like to know how to add Magento bundle product to current cart programmatically

The following is example of how to add a Magento bundle product to current cart programmatically

$params = array(
    'product' => 1,
    'related_product' => null,
    'bundle_option' => array( // your bundle option
        2=> 4,
        2=> array(
            0 => 5,
        ),
        13 => array(
            0 => 8,
            1 => 9,
        ),
    ),
    'options' => array( // your custom option
        2 => 'Test',
    ),
    'qty' => 2,
);
 
$cart = Mage::getSingleton('checkout/cart');
 
$product = new Mage_Catalog_Model_Product();
$product->load(1);
 
$cart->addProduct($product, $params);
$cart->save();
 
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
 
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments