Skip to content

Instantly share code, notes, and snippets.

@joshmiller83
Last active October 21, 2015 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshmiller83/e504444f41b76b8fbf1d to your computer and use it in GitHub Desktop.
Save joshmiller83/e504444f41b76b8fbf1d to your computer and use it in GitHub Desktop.
A quick example of how to use hook form alter to change the add to cart form.
<?php
/**
* Implements hook_form_alter()
*/
function THEMENAME_form_alter(&$form, &$form_state, $form_id) {
if (strpos($form_id,"cart_add_to_cart")) {
// load the node that is rendering the cart form
$node = node_load(array_pop(explode('_',$form_id)));
// hide the form
$form['#access'] = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment