Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

"Remove" link instead of checkbox in shopping cart


tim_o_boy

Recommended Posts

The shopping cart page has a checkbox next to each product that can be checked and then the re-calculate button is hit to remove that product. I'm looking for a way to display a "Remove" link (or button) instead of the checkbox that starts off the re-calculate.

 

I've come across a few ways to do this using javascript but I'd rather not rely on the user having javascript enabled in their browser.

 

Any help greatly appreciated.

Link to comment
Share on other sites

The shopping cart page has a checkbox next to each product that can be checked and then the re-calculate button is hit to remove that product. I'm looking for a way to display a "Remove" link (or button) instead of the checkbox that starts off the re-calculate.

 

I've come across a few ways to do this using javascript but I'd rather not rely on the user having javascript enabled in their browser.

 

Any help greatly appreciated.

 

Hi!

 

Edit catalog/includes/application_top.php near

 

switch ($HTTP_GET_VARS['action']) {

 

Add:

 

	case delete_product_from_cart' :	if(isset($HTTP_GET_VARS['pid'])) {
							$cart->remove($HTTP_GET_VARS['pid']);
						}
				tep_redirect(tep_href_link(FILENAME_SHOPPING_CART);
						  break;

 

And replace catalog/shopping_cart.php near

 

$info_box_contents[$cur_row][] = array('align' => 'center',
										 'params' => 'class="productListing-data" valign="top"',
										 'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']));

 

By this code:

 

$info_box_contents[$cur_row][] = array('align' => 'center',
										 'params' => 'class="productListing-data" valign="top"',
										 'text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'action=delete_product_from_cart&pid=' . $products[$i]['id']) . '">' . tep_image_button('button_delete.gif', IMAGE_BUTTON_DELETE) . '</a>');

 

That's it!

 

Kind Regards

Ga?tan Hermann

Link to comment
Share on other sites

Thanks Ga?tan - it works perfectly and is in fact a very simple way to do it.

 

Just a note to anyone else using this method, there were a couple of typos in Ga?tan's code:

 

This:

 case delete_product_from_cart' : if(isset($HTTP_GET_VARS['pid'])) {
$cart->remove($HTTP_GET_VARS['pid']);
}
tep_redirect(tep_href_link(FILENAME_SHOPPING_CART);
break;

 

Should read:

case 'delete_product_from_cart' : if(isset($HTTP_GET_VARS['pid'])){
		$cart->remove($HTTP_GET_VARS['pid']);
   }
   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
   break;

 

An apostrophe and a bracket missing.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...