Skip to content

Instantly share code, notes, and snippets.

@nicksantamaria
Created August 31, 2011 02:05
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 nicksantamaria/1182657 to your computer and use it in GitHub Desktop.
Save nicksantamaria/1182657 to your computer and use it in GitHub Desktop.
function melba_uc_init() {
...
if ($_GET['q'] == 'cart' && !empty($_POST)) {
// This is a continuation of a monstrosity born in
// sites/all/themes/melba/tempalates/views-view-table--cart-page.tpl.php
$cart_id = uc_cart_get_id(FALSE);
if (!empty($_POST['delete'])) {
// delete items from cart
foreach (array_keys(array_filter($_POST['delete'])) as $nid) {
melba_uc_cart_item_remove($nid);
}
}
if (!empty($_POST['qty'])) {
// Update quantities for cart item
foreach ($_POST['qty'] as $nid => $qty) {
if (!is_numeric($qty)) {
drupal_set_message(t('You must only enter a numeric figure in the quantity field.'), 'error');
continue;
}
melba_uc_cart_item_qty($nid, $qty);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment