Skip to content

Instantly share code, notes, and snippets.

@iledcom
Last active August 29, 2015 14:27
Show Gist options
  • Save iledcom/7179b5fdf3bbbb259fea to your computer and use it in GitHub Desktop.
Save iledcom/7179b5fdf3bbbb259fea to your computer and use it in GitHub Desktop.
Drupal 7 commerce_cart_add_to_cart_form
$form_idp= commerce_cart_add_to_cart_form_id(array(7));
//in this case product_id of 7 corresponds to a silver level
$productp = commerce_product_load(7);
$line_itemp = commerce_product_line_item_new($productp, 1); // 1 is quantity
$line_itemp->data['context']['product_ids'] = array(7);
$formp = drupal_get_form($form_idp, $line_itemp);
<?print drupal_render($formp);?>
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment