Index: uc_cart/uc_cart.module =================================================================== --- uc_cart/uc_cart.module (revision 225) +++ uc_cart/uc_cart.module (working copy) @@ -946,6 +946,15 @@ $description = $display_item['title']['#value'] . $display_item['description']['#value']; $form['items'][$i]['desc']['#value'] = $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'; @@ -980,7 +989,6 @@ $form['continue_shopping'] = array( '#type' => 'submit', '#value' => $cs_text, - '#submit' => array('uc_cart_view_form_submit'), ); $form['continue_shopping_text'] = array( '#type' => 'hidden', @@ -993,13 +1001,11 @@ $form['update'] = array( '#type' => 'submit', '#value' => t('Update cart'), - '#submit' => array('uc_cart_view_form_submit'), ); if (variable_get('uc_checkout_enabled', TRUE)) { $form['checkout'] = array( '#type' => 'submit', '#value' => t('Checkout'), - '#submit' => array('uc_cart_view_form_submit'), ); } @@ -1015,11 +1021,18 @@ unset($_SESSION['cart_order']); } + // If a remove button was clicked, set the quantity for that item to 0. + if (substr($form_state['clicked_button']['#name'], 0, 7) == 'remove-') { + $item = substr($form_state['clicked_button']['#name'], 7); + $form_state['values']['items'][$item]['qty'] = 0; + drupal_set_message(t('!product-title removed from your shopping cart.', array('!product-title' => $form_state['values']['items'][$item]['title']))); + } + // 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['clicked_button']['#value']) { // Continue shopping button. case $form_state['values']['continue_shopping_text']: $form_state['redirect'] = uc_cart_continue_shopping_url(); @@ -1597,12 +1610,7 @@ function uc_cart_update_item_object($cart) { if (is_object($cart)) { foreach ($cart->items as $item) { - if ($item['remove']) { - module_invoke($item['module'], 'update_cart_item', $item['nid'], unserialize($item['data']), 0); - } - else { - module_invoke($item['module'], 'update_cart_item', $item['nid'], unserialize($item['data']), $item['qty']); - } + module_invoke($item['module'], 'update_cart_item', $item['nid'], unserialize($item['data']), $item['qty']); } // Rebuild the cached cart items. Index: uc_product/uc_product.module =================================================================== --- uc_product/uc_product.module (revision 226) +++ uc_product/uc_product.module (working copy) @@ -1160,7 +1160,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( '#value' => node_access('view', $node) ? l($item->title, 'node/'. $node->nid) : check_plain($item->title), Index: uc_product_kit/uc_product_kit.module =================================================================== --- uc_product_kit/uc_product_kit.module (revision 227) +++ uc_product_kit/uc_product_kit.module (working copy) @@ -1049,7 +1049,7 @@ // Initialize table row $element = array(); $element['nid'] = array('#type' => 'value', '#value' => $kit->nid); - $element['module'] = array('#type' => 'value', '#value' => 'uc_product_kit'); + $element['remove'] = array('#type' => 'submit', '#value' => t('Remove')); $element['remove'] = array('#type' => 'checkbox'); $element['title'] = array('#value' => l($kit->title, 'node/'. $kit->nid)); $element['qty'] = array(