$appEmulation = Mage::getSingleton("core/app_emulation");
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
$customer = Mage::getModel("customer/customer")->load($customerId)->setStoreId($storeId);
Mage::getSingleton("customer/session")->setCustomer($customer);
$cart = Mage::getSingleton("checkout/cart");
//params can have any value from following
$params = array("related_product" => null, "links" => $links, "options" => $paramOption, "qty" => $qty, "product" => $productId);
OR
$params = array("related_product" => null, "super_group" => $super_group, "product" => $productId);
OR
$params = array("related_product" => null, "super_attribute" => $super_attribute, "options" => $paramOption, "qty" => $qty, "product" => $productId);
OR
$params = array("related_product" => null, "bundle_option" => $bundle_option, "bundle_option_qty" => $bundle_option_qty, "options" => $paramOption, "qty" => $qty, "product" => $productId);
OR
$params = array("related_product" => null, "options" => $paramOption, "qty" => $qty, "product" => $productId);
$cart->addProduct($product, $params);
$cart->save();
Mage::getSingleton("checkout/session")
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
i tried this code but it isn't seems to work, there is something else that have to be set in checkout session before adding product to cart.
Please Help.