diff --git a/foxycart.module b/foxycart.module
index e05c84f..88771ec 100755
--- a/foxycart.module
+++ b/foxycart.module
@@ -421,4 +421,98 @@ function foxycart_log($data, $label = NULL) {
 	}
 }
 
-?>
\ No newline at end of file
+
+
+/**
+* Create an HTML 'add to cart' href link
+* 
+* Example:
+* @code
+*   print foxycart_purchase_link("Add to cart", array('code' => "my-product-code", 'name' => "My Product Name", "price" => "5"));
+* @endcode
+* 
+* @param string $text
+*   The translated link text for the anchor tag. 
+* @param array $attributes
+*   Foxycart key => value array to be attached as a query. It should at least include 'code', 'name' and 'price'
+* @param array $options
+*   An associative array of additional options. See the l() function for more details.
+* 
+* @return string
+*   An HTML string containing an add-to-cart link
+* 
+* @see l()
+*/
+function foxycart_purchase_link($text, $attributes, $options = array()) {
+  $query = array();
+  foreach ($attributes as $attr => $val) {
+    $query[foxycart_get_product_attribute($attributes['code'], $attr, $val)] = $val;
+  }
+
+  $link_options = array(
+    'attributes' => array('class' => array('foxycart', 'purchase-link')),
+    'query' => $query,
+  );
+
+  $link_options = array_merge_recursive($link_options, $options);
+
+  return l($text, 'https://'.variable_get('foxycart_subdomain', '')."/cart", $link_options);
+}
+
+/**
+* Get an 'add to cart' form
+* 
+* This returns a form that contains a single submit button that will add a product to a cart. Example:
+* @code
+*   print drupal_render(drupal_get_form('foxycart_purchase_link_form', "Add to cart", array(
+*     'code' => "my-product-code", 
+*     'name' => "My Product Name", 
+*     'price' => "5"
+*   ));
+* @endcode
+* 
+* @param string $text
+*   The translated link text for the submit button. 
+* @param array $attributes
+*   Foxycart key => value array to be attached as a query. It should at least include 'code', 'name' and 'price'
+* 
+* @return form
+*   A form array reader to be rendered using drupal_render()
+*/
+function foxycart_purchase_link_form($form, &$form_state, $text, $attributes) {
+  $form['#action'] = 'https://'.variable_get('foxycart_subdomain', '')."/cart";
+  $form['purchase'] = array('#type' => 'submit', '#value' => $text);
+
+  foreach ($attributes as $attr => $val) {
+    $form[$attr] = array(
+      '#type' => 'hidden',
+      '#value' => $val,
+      '#attributes' => array('name' => array(foxycart_get_product_attribute($attributes['code'], $attr, $val))),
+    );
+  }
+  // Unset form items that confuse foxycart
+  $form['#pre_render'] = array('foxycart_remove_form_items');
+
+  return $form;
+}
+
+/**
+* Callback to remove form items that confuse the foxycart API
+* 
+* It removes `form_token`, `form_id` and `form_build_id`. 
+* It should be used in conjuction with From API's `#pre_render`.
+* 
+* @param array $form
+*   The form
+* 
+* @return form
+*   The form with the offending items removed
+* 
+* @ingroup callbacks
+*/
+function foxycart_remove_form_items($form) {
+  unset($form['form_token']);
+  unset($form['form_id']);
+  unset($form['form_build_id']);
+  return $form;
+}
\ No newline at end of file
