Community Add-Ons

Maintainers: dave111
Add file to this package
Top » Features

Automatic remove button in shopping cart
for osCommerce Online Merchant v2.2

This contribution will make the remove checkbox in the shopping cart automatically update and remove the item when customer clicks the checkbox (no need for them to click "update")

1 ) Add this between the <head></head> tags in shopping_cart.php (around line 25)

--------------------------------------
<script type="text/javascript" language="JavaScript"><!--
function DoSubmission() {
document.cart_quantity.submit();
}
//--></script>
----------------------------------------

2 ) Search for:

----------------------------------------
'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']));

----------------------------------------

Change to:

----------------------------------------

'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id'], ' ', 'onClick="DoSubmission();"'));
----------------------------------------

3 ) in file includes/functions/html_output.php search for: (around line 189)

----------------------------------------

if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {
$selection .= ' CHECKED';
------------------------------------------

Change to:
-----------------------------------------

if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {
$selection .= '';
-----------------------------------------

and thats it, enjoy

Legend:  Download   Report
Expand All / Collapse All
one simple step, minor addition yourmanstan 18 Apr 2006  

just to make it a little clearer, helps users understand that the checkbox will remove the product

in shopping_cart.php

find
'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']));

change to

//'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']));
'text' => 'Remove?<br>' . tep_draw_checkbox_field('cart_delete[]', $products[$i]['id'],'', 'onclick="document.cart_quantity.submit();"',false));//auto update cart

Update ur quantities with javascript *Ringo* 25 Feb 2006  
Just one simple step to to it. deep-silver 23 Feb 2006  
Automatic Remove Button In Shopping Cart Remulon 23 Feb 2006  
Automatic remove button in shopping cart v2 mr_absinthe 14 Feb 2006  
Automatic remove button in shopping cart v2 jGirlyGirl1 13 Feb 2006  
Automatic remove button in shopping cart v2 jGirlyGirl1 13 Feb 2006  
the same is good when changing quantity mikethebike 31 Jan 2006  
Updated Sir.K.O. 7 Jul 2005  
Automatic remove button in shopping cart dave111 6 Jul 2005