Skip to content

Instantly share code, notes, and snippets.

@iledcom
Created September 7, 2015 11:05
Show Gist options
  • Save iledcom/e318590338cb89458ebb to your computer and use it in GitHub Desktop.
Save iledcom/e318590338cb89458ebb to your computer and use it in GitHub Desktop.
Drupal7 concluded the "add to cart"
<?php
$form_id
= commerce_cart_add_to_cart_form_id(array($product->product_id));
$line_item = commerce_product_line_item_new($product);
$line_item->data['context']['product_ids'] = array($product->product_id);
$form = drupal_get_form($form_id, $line_item);
// render your $form somewhere
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment