Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Remove products from the chart with one click


Salvo

Recommended Posts

Hi all

 

I am looking for a way to use an image instead of a "tick box and update chart" to remove products from the chart.

 

Can someone who has implemented it post the small hack?

or can someone direct me on how to implement it?

 

Thanks you

 

Sal

Link to comment
Share on other sites

  • 2 weeks later...

I'm also looking to do the same thing. A button or text link that quickly and easily deletes or removes a product from the shopping cart with one click. Any ideas?

 

Thanks,

Mike

Link to comment
Share on other sites

Around lines 111-3 of shopping_cart.php, replace

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

with

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

Around line 330 of includes/application_top.php, add

      case 'remove_product':if (isset($HTTP_GET_VARS['product_id']) && tep_not_null($HTTP_GET_VARS['product_id'])) $cart->remove($HTTP_GET_VARS['product_id']);
                           break;

between (about lines 329-30)

    switch ($HTTP_GET_VARS['action']) {
     // customer wants to update the product quantity in their shopping cart

Add to includes/languages/english/shopping_cart.php (or whatever language):

  define('BUTTON_REMOVE_FROM_CART', 'Remove from cart');

and add an image for the remove from cart button to includes/languages/english/images/buttons (or whatever language).

 

Hth,

Matt

Link to comment
Share on other sites

For MS1, around lines 47-50 of includes/modules/order_details.php

// Delete box only for shopping cart
   if (strstr($PHP_SELF, FILENAME_SHOPPING_CART)) {
     echo '    <td align="center" valign="top">' . tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']) . '</td>' . "\n";
   }

change to

// Delete box only for shopping cart
   if (strstr($PHP_SELF, FILENAME_SHOPPING_CART)) {
     echo '    <td align="center" valign="top"><a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'action=remove_product&product_id=' . $products[$i]['id']) . '">' . tep_image_button('button_remove_from_cart.gif', BUTTON_REMOVE_FROM_CART) . '</a></td>' . "\n";
   }

The application_top.php code moves to around lines 308-9.

 

Hth,

Matt

Link to comment
Share on other sites

Thank you very much Matt, the code works very well.

 

I also have another question about Removing products..

 

how to have an image saying (remove all products)

 

ie: if there are 5 products in the shopping cart, remove all with 1 click

 

Thanks

 

Salvo

Link to comment
Share on other sites

How about changing (around line 339 of includes/application_top.php)

                                if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array()))) {

to

                                if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array())) || ($HTTP_POST_VARS['cart_quantity'][$i] == 0)) {

to make a quantity of 0 remove the item. Or am I missing something?

 

To remove all products, just add a button linking to a page with an action of remove_all or something like that. Then add a new action to includes/application_top.php:

action 'remove_all':  $cart->reset();break;

Hth,

Matt

Link to comment
Share on other sites

Hi Mat

I can't make ti work:

 

To remove all products,

 

just add a button linking to a page with an action of remove_all or something like that.

 

I have put this image to remove all in the shopping cart:

 

<?php echo '<a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'action=remove_all') . '">' . tep_image_button('button_remove_from_cart.gif', IMAGE_BUTTON_UPDATE_CART) . '</a>'; ?>

 

 

Then add a new action to includes/application_top.php:

action 'remove_all': $cart->reset();break;[/code]

Hth,

 

How and where do I have to place it in application_top? I just tried to place it as it is some where and gives me errors.. I guess has to be placed somewhere specific and with more code.

 

Thanks for help

 

salvo

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...