Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Automatic Remove Button in Shopping Cart


Remulon

Recommended Posts

Posted

Is anyone using this type of functionality?

 

Or is everyone happy with the two-click process to remove an item from your cart?

 

I recently installed this mod:

http://www.oscommerce.com/community/contributions,3326

 

Which is basically:

--------------------------------------------------------------------
-- Add this script to the <head> of shopping_cart.php
--------------------------------------------------------------------
<script type="text/javascript" language="JavaScript">
 <!--
 function DoSubmission() {
document.cart_quantity.submit();
}
 //-->
</script>

--------------------------------------------------------------------
-- In shopping_cart.php Find:
--------------------------------------------------------------------
'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']));

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

 

Which removes the product from the cart as soon as the customer clicks the remove checkbox (one-click process).

 

But I want to use an image/button instead of a checkbox, can anyone help?

Posted

The code in my previous post can be reduced to:

 

----------------------------------------
-- In shopping_cart.php Find:
----------------------------------------
'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']));

----------------------------------------
-- And Replace with:
----------------------------------------
'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id'], '', 'onClick="document.cart_quantity.submit();"'));

 

And the mod still works.

 

I still need to change the checkbox to an image/button though.

 

Any ideas?

Posted

just use the tep_image_submit

'text' => tep_image_submit('some_image_filename.gif', 'Some Image Title');

if its within the form it will submit it.

Posted
just use the tep_image_submit

 

'text' => tep_image_submit('some_image_filename.gif', 'Some Image Title');

 

if its within the form it will submit it.

 

That simply updates the form, similar to when you change the quantity and update.

Posted

but it shows the image that you wanted too right? ok you see I have no idea what other details are there. So add a hidden field and retry

'text' => tep_image_submit('some_image_filename.gif', 'Some Image Title') . tep_draw_hidden_field('cart_delete[]', $products[$i]['id']);

Posted

I added the tep_draw_hidden_field command

 

tep_draw_hidden_field('cart_delete[]', $products[$i]['id'])

 

but it makes all buttons remove all items from the cart... including the update button.

Posted

there must be some other code that assumes that checkboxes are still in place. You have to modify that other code to simply check the id. Now it checks the checkbox value I guess.

Posted

Ok folks, here's my solution...

 

in application_top.php find:

switch ($HTTP_GET_VARS['action']) {

insert after:

	  // customer wants to remove a product from their shopping cart
  case 'remove_product' : $cart->remove($HTTP_GET_VARS['products_id']);
						  tep_redirect(tep_href_link($goto));
						  break;

 

 

in shopping_cart.php find:

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

replace with:

'text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'action=remove_product&products_id='.$products[$i]['id']) . '">' . tep_image_button('button_update_cart.gif', 'Remove') . '</a>');

 

 

Sorry there's no line numbers, but I have a few mods installed so my line numbers would be of no use anyway.

Thanks for your help enigma1.

Archived

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

×
×
  • Create New...