Page 1 of 2
[MOD] Delete button on cart
Posted: Fri Feb 26, 2010 4:55 am
by sandi
is it possible to make a small button, or something, which will delete/remove item from cart window?
Re: delete button on cart
Posted: Sat Feb 27, 2010 8:28 am
by SXGuy
Just an idea, off the top of my head, havent tested this though.
BTW this is for 1.3.2 so other revs may vary
template/checkout/cart.tpl line 23
Code: Select all
<td align="center"><input type="checkbox" name="remove[<?php echo $product['key']; ?>]" /></td>
Replace with
Code: Select all
<td align="center"><a onclick="$('#cart').submit();" name="remove[<?php echo $product['key']; ?>]" class="button"><span>Remove</span></a></td>
Make a copy of your old cart.tpl file first before you try this as i am only guessing to whether it will work.
Re: delete button on cart
Posted: Sat Feb 27, 2010 2:00 pm
by sandi
SXGuy wrote:Just an idea, off the top of my head, havent tested this though.
BTW this is for 1.3.2 so other revs may vary
template/checkout/cart.tpl line 23
Code: Select all
<td align="center"><input type="checkbox" name="remove[<?php echo $product['key']; ?>]" /></td>
Replace with
Code: Select all
<td align="center"><a onclick="$('#cart').submit();" name="remove[<?php echo $product['key']; ?>]" class="button"><span>Remove</span></a></td>
Make a copy of your old cart.tpl file first before you try this as i am only guessing to whether it will work.
Thx man it works..much appreciated

Re: delete button on cart
Posted: Sat Feb 27, 2010 7:59 pm
by SXGuy
No probs

glad i could help!
Re: [MOD] Delete button on cart
Posted: Wed Mar 03, 2010 11:58 pm
by alexkor
SXGuy, How to do this on opencart 1.4. I have added the code, but it can't work.
Can you help me?
Re: [MOD] Delete button on cart
Posted: Thu Mar 04, 2010 7:34 am
by SXGuy
Ill try and help you, if im honest, ive only just gotten into 1.40 myself, so im a newbie with that
Lets see...
catalog/view/theme/default/template/checkout/cart.tpl line 32
Code: Select all
<td align="center"><input type="checkbox" name="remove[<?php echo $product['key']; ?>]" /></td>
replace with
Code: Select all
<td align="center"><a onclick="$('#cart').submit();" name="remove[<?php echo $product['key']; ?>]" class="button"><span>Remove</span></a></td>
Re: [MOD] Delete button on cart
Posted: Thu Mar 04, 2010 8:20 am
by imadam
didn't seem to work for me, though i have modified the cart page a tad i don't think that's why it's not working. i think it's because the form would be looking for a checked input box and then remove the item based on thats key, which isn't happening here. any idea on a fix? also would be nice if JavaScript wasn't required to remove the item as if a user had js disabled there'd be no way to remove the item
Re: [MOD] Delete button on cart
Posted: Thu Mar 04, 2010 6:58 pm
by SXGuy
Your right it doesnt work, just tried it myself.
I think the only way it would work is to replace the onclick with a JS function that removes the item.
I dont know how it could be done without JS to be honest.
Re: [MOD] Delete button on cart
Posted: Fri Mar 05, 2010 8:24 am
by imadam
SXGuy wrote:Your right it doesnt work, just tried it myself.
I think the only way it would work is to replace the onclick with a JS function that removes the item.
I dont know how it could be done without JS to be honest.
well a link to a page that simple removes the item based on key which then redirects back to cart will do fine without the need for js. js should only be used imo for when you want to remove without page refresh, but atm one is needed for it to disappear.
thinking about it i quite like the old standard method of a checkbox as then you can remove more then one item at a time. much quicker then a page refresh every time.
Re: [MOD] Delete button on cart
Posted: Fri Jun 11, 2010 4:20 am
by benisv
SXGuy wrote:Ill try and help you, if im honest, ive only just gotten into 1.40 myself, so im a newbie with that
Lets see...
catalog/view/theme/default/template/checkout/cart.tpl line 32
Code: Select all
<td align="center"><input type="checkbox" name="remove[<?php echo $product['key']; ?>]" /></td>
replace with
Code: Select all
<td align="center"><a onclick="$('#cart').submit();" name="remove[<?php echo $product['key']; ?>]" class="button"><span>Remove</span></a></td>
1. I tried this on 1.4.7 and i got the buttons on but if i click it nothing hapend , i mean that product still remain on cart ,any idea why?
2. Also can any one help me out to do the same but on right side on cart ,side cart

something like this ,let say i made a button call "list_remove_btn" and i uploud it it \catalog\view\theme\default\image

Re: [MOD] Delete button on cart
Posted: Fri Jun 11, 2010 4:49 am
by Xsecrets
you could upgrade to 1.4.8 which has this out of the box.
Re: [MOD] Delete button on cart
Posted: Fri Jun 11, 2010 5:01 am
by benisv
Yes i know i could but i got some old modules that i can't run without ,but until i got updates for those i try to make it as useful as I can ,thanks
Re: [MOD] Delete button on cart
Posted: Fri Jun 11, 2010 3:22 pm
by SXGuy
Best advice would be to download 1.4.8 and compare the changes between your version and that version, and port them over so you have what you want
Re: [MOD] Delete button on cart
Posted: Sat Jan 15, 2011 12:03 am
by borrie
Ok i got it working.
For those in need:
<a onclick="$('#cart').submit();" class="delete">
<input type="checkbox" name="remove[<?php echo $product['key']; ?>]" class="checkbox" checked="checked" />
<img src="catalog/view/theme/default/image/redcross.jpg" />
</a>
and than in your css:
.delete .checkbox{
display:none;
}
Re: [MOD] Delete button on cart
Posted: Mon Jan 17, 2011 7:33 pm
by philbydevil
Almost there borrie. Using the code to replace the checkbox works, but if I change the quantity of an item and click "Update", it removes the item from my cart instead.
Re: [MOD] Delete button on cart
Posted: Mon Jan 17, 2011 7:46 pm
by philbydevil
<td align="center"><a onclick="$('#cart').submit();" name="remove[<?php echo $product['key']; ?>]" class="button"><span>Remove</span></a></td>
This seems to do the opposite to borrie's code. I can update the quantity, but the new "Remove" button doesn't delete the item.
Re: [MOD] Delete button on cart
Posted: Mon Jan 02, 2012 12:29 am
by dpanov
Any ideas how this can be implemented for 1.5.1.3?
Re: [MOD] Delete button on cart
Posted: Sat Feb 11, 2012 7:44 am
by Spacer
Ok ive done it!,
<a onclick="$('#cart').submit();" class="delete" />
<input type="checkbox" id="<?php echo $product['key']; ?>" name="remove[<?php echo $product['key']; ?>]" class="checkbox"/>
<img src="catalog/view/theme/default/image/image.png" onclick="remove('<?php echo $product['key']; ?>');"/>
</a>
---END OF THE DOCUMENT BEFORE <FOOTER>
<script language="javascript" type="text/javascript">
function remove(id)
{
document.getElementById(id).checked=true;
}
</script>
CSS
----
.delete .checkbox{
display:none;
}
Re: [MOD] Delete button on cart
Posted: Mon Feb 13, 2012 4:40 am
by jackson
a slight mod for 1.5.1.3 worked for me
<a onclick="$('#basket').submit();" class="delete" />
<input type="checkbox" id="<?php echo $product['key']; ?>" name="remove[]" value="<?php echo $product['key']; ?>" style="display:none;"/>
<img src="catalog/view/theme/default/image/close.png" onclick="remove('<?php echo $product['key']; ?>');"/>
</a>
Re: [MOD] Delete button on cart
Posted: Fri Jan 25, 2013 3:01 am
by iomedesimo
Please help me....
i have the 1.5.1.3 version and don't work...
I'd really like this but do not know how