I've tried deleting the one cookie that is set for end of session. It does empty the cart, but also logs me out.... How can I set it to just empty the cart?
bump?
I´m trying to figure it out too, the only thin I´ve found up to now is in the helpers/cart.php removeCartFromSession();
I´m working on from there if I find it out I´ll let you know.
;)
I got a solution, it works I don´t know ow good it is.
I installed the "Easy Source Module" With its help added a function to a page which you could define upon opening that page a function is called via "Easy Source Module"
<?php
function clearCart() {
if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'config.php');
if(!class_exists('VirtueMartCart')) require(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
$noCart = VirtueMartCart::removeCartFromSession();
return $clearCart;
}
clearCart();
?>
hope this helps
VM 2.0.14, Joomla 1.5.26, PHP 5.2.something
I too wanted an empty cart button. So I added the following code to components/com_virtuemart/controllers/cart.php:
public function emptycart() {
$mainframe = JFactory::getApplication();
/* Load the cart helper */
$cart = VirtueMartCart::getCart();
$cart->emptyCart();
$mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_CART_EMPTIED_SUCCESSFULLY'));
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'));
}
Then, in components/com_virtuemart/views/cart/tmpl/default_pricelist.php, I added below the table row that puts a horizontal rule under the last product in the cart:
<?php
if (count( $this->cart->products ) > 0) {
?>
<tr class="sectiontableentry1">
<td> </td>
<td align="left"></td>
<td align="center"></td>
<td align="Center"><a class="vmicon vm2-remove_from_cart" title="<?php echo JText::_ ('COM_VIRTUEMART_CART_EMPTY') ?>" align="center" href="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=cart&task=emptycart') ?>"> </a><?php echo JText::_ ('COM_VIRTUEMART_CART_EMPTY') ?></td>
</tr>
<?php
}
?>
You could, of course, use a colspan to avoid the empty single table cells to the left of the empty-the-cart-one, but I have already amended default_pricelist to include optional display / no-display of SKUs, discounts and product states, so needed to have cell inclusion / exclusion code that I have removed from the code fragment above. You also need to add COM_VIRTUEMART_CART_EMPTY="Empty the whole cart"
COM_VIRTUEMART_CART_EMPTIED_SUCCESSFULLY="Cart was emptied successfully"
to language/<your lang>/<your lang>.com_virtuemart.ini
This seems to work fine for me - I hope it helps someone else.
Mark