=== modified file 'uc_cart/uc_cart.module' --- uc_cart/uc_cart.module 2010-12-09 14:01:40 +0000 +++ uc_cart/uc_cart.module 2011-02-03 17:41:51 +0000 @@ -883,7 +883,7 @@ if (!isset($_SESSION['uc_cart_id'])) { return; } - + // Get the current contents of the cart. $items = uc_cart_get_contents($uid); @@ -963,6 +963,15 @@ $description = $display_item['title']['#markup'] . $display_item['description']['#markup']; $form['items'][$i]['desc']['#markup'] = $description; + if (isset($form['items'][$i]['remove'])) { + // Backward compatibility with old checkbox method. + if ($form['items'][$i]['remove']['#type'] == 'checkbox') { + $form['items'][$i]['remove'] = array('#type' => 'submit', '#value' => t('Remove')); + } + + $form['items'][$i]['remove']['#name'] = 'remove-' . $i; + } + $form['items'][$i]['title']['#type'] = 'value'; $form['items'][$i]['description']['#type'] = 'value'; @@ -999,7 +1008,6 @@ $form['actions']['continue_shopping'] = array( '#type' => 'submit', '#value' => $cs_text, - '#submit' => array('uc_cart_view_form_submit'), ); $form['continue_shopping_text'] = array( '#type' => 'hidden', @@ -1012,13 +1020,11 @@ $form['actions']['update'] = array( '#type' => 'submit', '#value' => t('Update cart'), - '#submit' => array('uc_cart_view_form_submit'), ); if (variable_get('uc_checkout_enabled', TRUE)) { $form['actions']['checkout'] = array( '#type' => 'submit', '#value' => t('Checkout'), - '#submit' => array('uc_cart_view_form_submit'), ); } @@ -1034,11 +1040,18 @@ unset($_SESSION['cart_order']); } + // If a remove button was clicked, set the quantity for that item to 0. + if (substr($form_state['triggering_element']['#name'], 0, 7) == 'remove-') { + $item = substr($form_state['triggering_element']['#name'], 7); + $form_state['values']['items'][$item]['qty'] = 0; + drupal_set_message(t('!product-title removed from your shopping cart.', array('!product-title' => $form['items'][$item]['title']['#markup']))); + } + // Update the items in the shopping cart based on the form values. uc_cart_update_item_object((object)$form_state['values']); // Specify the appropriate redirect based on the button used to submit. - switch ($form_state['values']['op']) { + switch ($form_state['triggering_element']['#value']) { // Continue shopping button. case variable_get('uc_continue_shopping_text', t('Continue shopping')): $form_state['redirect'] = uc_cart_continue_shopping_url(); @@ -1655,12 +1668,7 @@ function uc_cart_update_item_object($cart) { if (is_object($cart)) { foreach ($cart->items as $item) { - if ($item['remove']) { - module_invoke($item['module'], 'uc_update_cart_item', $item['nid'], unserialize($item['data']), 0); - } - else { - module_invoke($item['module'], 'uc_update_cart_item', $item['nid'], unserialize($item['data']), $item['qty']); - } + module_invoke($item['module'], 'uc_update_cart_item', $item['nid'], unserialize($item['data']), $item['qty']); } // Rebuild the cached cart items. === modified file 'uc_product/uc_product.module' --- uc_product/uc_product.module 2011-01-04 21:49:19 +0000 +++ uc_product/uc_product.module 2011-02-03 16:01:33 +0000 @@ -1187,7 +1187,7 @@ $element = array(); $element['nid'] = array('#type' => 'value', '#value' => $node->nid); $element['module'] = array('#type' => 'value', '#value' => 'uc_product'); - $element['remove'] = array('#type' => 'checkbox'); + $element['remove'] = array('#type' => 'submit', '#value' => t('Remove')); $element['title'] = array( '#markup' => node_access('view', $node) ? l($item->title, 'node/' . $node->nid) : check_plain($item->title), === modified file 'uc_product_kit/uc_product_kit.module' --- uc_product_kit/uc_product_kit.module 2010-12-29 16:45:17 +0000 +++ uc_product_kit/uc_product_kit.module 2011-02-03 16:01:34 +0000 @@ -1061,7 +1061,7 @@ $element = array(); $element['nid'] = array('#type' => 'value', '#value' => $kit->nid); $element['module'] = array('#type' => 'value', '#value' => 'uc_product_kit'); - $element['remove'] = array('#type' => 'checkbox'); + $element['remove'] = array('#type' => 'submit', '#value' => t('Remove')); $element['title'] = array('#markup' => l($kit->title, 'node/' . $kit->nid)); $element['qty'] = array( '#type' => 'textfield',