I've managed to add a delete button beside each product in the shopping cart sidebox, using part of a script from an osCommerce mod.
In templates/sideboxes/tpl_shopping_cart.php I added this script at the start before $content ="";
PHP Code:
?>
<script type="text/javascript">
<!--
function mark(pid) {
document.forms["remove_product"].elements["cart_delete[]"][0].value=pid;
document.forms["remove_product"].elements["products_id[]"][0].value=pid;
document.remove_product.submit();
}
var sURL = document.URL.toString();
if (sURL.indexOf("?") > 0){
urlsplitter = '';
} else {
urlsplitter = '?';
}
document.write('<form ');
document.write(' name="remove_product" ');
document.write(' action="' + document.URL + urlsplitter + '&action=update_product"');
document.write(' method="post">');
//one element is not an array so add 2 of each!
document.write('<input type="hidden" name="products_id[]">');
document.write('<input type="hidden" name="cart_delete[]">');
document.write('<input type="hidden" name="products_id[]">');
document.write('<input type="hidden" name="cart_delete[]">');
document.write('</form>');
document.write('<form ');
document.write(' name="cart_box" ');
document.write(' action="' + document.URL + urlsplitter + '&action=update_product"');
document.write(' method="post">');
//-->
</script>
<?php
I dropped a delete icon into my images folder and added the following line before <span class="cartNewItem"> and <span class="cartOldItem">:
PHP Code:
<div class="removeProduct"><a href="javascript:void(mark(\'' . $products[$i]['id'] . '\'));">' . '<img src="images/small_delete.gif" border="0" height="16" width="16"></a></div>
To make the delete icon display to the right of each product, I added this line to stylesheet.css:
HTML Code:
.removeProduct {float:right;margin:0px 0px 0px 2px;}
Seems to be working OK... I'd like to get the delete icons to line up on the right, but I'm not sure how to do this ...
Bookmarks