malnomany Posted May 28, 2009 Share Posted May 28, 2009 Hello all, thought I am not expert with PHP but I could create a simple shopping cart for my website but I need help developping it. hope someone will help me out. I need to add a remove button to each item in the table when a user select an item from the list and have the calculation work as well. here is the website: www.clothesmanufacture.com anyone can help ? Link to comment https://forums.phpfreaks.com/topic/160024-need-help-with-shopping-cart/ Share on other sites More sharing options...
will35010 Posted May 28, 2009 Share Posted May 28, 2009 Sure. Post your code and we'd be glad to look at it. Link to comment https://forums.phpfreaks.com/topic/160024-need-help-with-shopping-cart/#findComment-844154 Share on other sites More sharing options...
mo Posted May 28, 2009 Share Posted May 28, 2009 Add a link or image button for the delete and process the request on click <?php if($_GET["action"] == "remove_item" && $_GET["id"] != ""){ //Delete item logic here..... } <input type=\"button\" alt=\"Delete\" name=\"btnDelete\" id=\"btnDelete\" value=\"\" onClick=\"window.location.href='mysite.com/cart.php?action=remove_item&item_id=$id&'\"> ?> Link to comment https://forums.phpfreaks.com/topic/160024-need-help-with-shopping-cart/#findComment-844162 Share on other sites More sharing options...
rv20 Posted May 28, 2009 Share Posted May 28, 2009 There is a really cool SC drag and drop, i don't think it would be hard setting it up either, http://demos111.mootools.net/Drag.Cart Link to comment https://forums.phpfreaks.com/topic/160024-need-help-with-shopping-cart/#findComment-844174 Share on other sites More sharing options...
malnomany Posted May 29, 2009 Author Share Posted May 29, 2009 Thank you all for your replies. I really appreciate it. I did add a remove button to each item that any customer would choose from the list. but I still have a problem with the code itself. I didn't wirte the code as I am not an expert with php, this is why I am seeking help. when I click remove , it does remove the entry but when I add another item it gives me an empty entry and it miss the calculation. I am going to post the code so you will have a look at it, and if someone can edit it to get it work correctly, I will be really gratefull to him. and if not, is it possible for someone to write another code from the begining to make an order form like the one on the website ? a better code I mean that allow customers to remove any item they choose from the list. will be waiting for answers with patience. thanks in advance for everyone. here's the current code: <? if($_POST['AddToCart'] && $_POST["ProductName"] || $_SESSION['CustomerOrder']){ if( $_POST["ProductName"] ){ $Order = array(); $ShoppingSession = array(); $IdProduct = $_POST['IdProduct']; $ProductName = $_POST['ProductName']; $Size = $_POST['Size']; $Quantity = $_POST['Quantity']; $ProductPrice = ($_POST['ProductPrice']) ; $Totalprice = ( $Quantity * $ProductPrice) ; $OrderPrice = ( $_SESSION['OrderPrice'] + $Totalprice); $_SESSION['OrderPrice'] = $OrderPrice; $CustomerOrder = $_SESSION['CustomerOrder'].'--'.$IdProduct.'|'.$ProductName.'|'.$Size.'|'.$Quantity.'|'.$ProductPrice.'|'.$Totalprice.'|'.$OrderPrice; $CustomerOrder = trim($CustomerOrder,'--'); $_SESSION['CustomerOrder'] = $CustomerOrder; // echo $CustomerOrder; $CustomerOrderArray = split('--',$CustomerOrder); }else{ $CustomerOrder = $_SESSION['CustomerOrder'] ; $CustomerOrder = trim($CustomerOrder,'--'); $CustomerOrderArray = split('--',$CustomerOrder); } if($_REQUEST['r']) // this is the code of the remove button which doesn't work $OrderPrice = ( $_SESSION['OrderPrice'] -$toRemove);s $toRemove = ($_REQUEST['productPrice'])*($_REQUEST['quantity']); $CustomerOrderArray = split('--',$CustomerOrder); $CustomerOrderArray[$_REQUEST['IdShopping']]=''; $CustomerOrder = ''; foreach($CustomerOrderArray as $ke=>$val){ $CustomerOrder .= '--'.$val; } $_SESSION['CustomerOrder']=$CustomerOrder ; $CustomerOrder = str_replace('----','',$CustomerOrder); $CustomerOrder = trim($CustomerOrder,'--'); $CustomerOrderArray = split('--',$CustomerOrder); } if ( $CustomerOrder){ ?> Link to comment https://forums.phpfreaks.com/topic/160024-need-help-with-shopping-cart/#findComment-845148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.