Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

function to kill the cart?


dreamscape

Recommended Posts

Posted

is there a built in function in OSC to kill the cart with one click? ie "empty cart" that most shopping cart systems have...

 

I have searched back to April and haven't found anything on adding this function in...

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Posted

well you know what they say... if you want something done, you have to do it yourself:

 

added this to the action switch in application_top.php

      // customer wants to empty the entire cart

     case 'kill_cart' :     $products = $cart->get_products();

       $size = sizeof($products);

       for ($i=0; $i<$size; $i++) {

                                 $cart->remove($products[$i]['id']);

        }

   break;

 

then either create a form whose "action=kill_cart" or a link like:

<a href="<?php echo tep_href_link(FILENAME_SHOPPING_CART, 'action=kill_cart', 'NONSSL'); ?>">Text or image here</a>

 

seems to work good.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Posted

now you tell me it is that simple...

 

I had not investigated all of the $cart-> functions...

 

thanks Harold

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Posted

What file(s) do I need to edit to use the 'cart reset' feature?

 

Cheers,

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Posted
What file(s) do I need to edit to use the 'cart reset' feature?

 

Cheers,

Tony

 

/includes/application_top.php:

 

in this file towards the bottom before the lines:

      // customer wants to update the product quantity in their shopping cart

     case 'update_product' : $size = sizeof($HTTP_POST_VARS['products_id']);

 

insert this:

      // customer wants to empty the entire cart

     case 'kill_cart' : $cart->reset(true);

   break;

 

then in shopping_cart.php find where you want to place the "emtpy cart" button or text link and use:

<a href="<?php echo tep_href_link(basename($PHP_SELF), 'action=kill_cart', 'NONSSL'); ?>">Text or image here</a>

 

replacing the "Text or image here" part with either the text or image you want shown to empty the cart.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Archived

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

×
×
  • Create New...