How can I add products to cart programmatically?
To add particular product id you have your product id and current user id you can easily do.
Send the Product id and user id to this function this will add your product to the user cart. 

This is the custom function used. The main part here is the commerce_product_line_item_new() and commerce_cart_product_add() this will add the product to that particular user cart. 

function add_product_to_cart($pid,$uid=0){
    global $user;
    $uid = isset($uid) &amp;&amp; !empty($uid) ? $uid : $user-&gt;uid;
    $line_item = commerce_product_line_item_new(commerce_product_load($pid));
    commerce_cart_product_add($uid, $line_item);
}


Hope this will help :)