Page 1 of 2

shopping cart delete item

Posted: Thu Oct 02, 2014 2:53 am
by terrenuit
Hi,
my shopping cart script has a problem:
if I have serveral items, when I want to delete the last or second....last item,
it is always the first item has been delete,
I cannot delete the item that I want.
I wish someone can help me,
it is my script:

<td align="center" > <img src="photos/garbage.jpg" width="23" height="40" border="0" usemap="#Map"> <map name="Map">
<area shape="rect" coords="2,0,34,47" href="cancel.php?name=<?php print $product['ref'] ?>"></map>

Re: shopping cart delete item

Posted: Thu Oct 02, 2014 3:36 am
by phpdeveloper1
terrenuit wrote:...............Hi,
my shopping cart script has a problem:
.........................................
Which shopping cart script are you using ?

Re: shopping cart delete item

Posted: Thu Oct 02, 2014 4:04 am
by terrenuit
@phpdeveloper1
I created my shopping cart by myself, on part script is:
<td align="center" > <img src="photos/garbage.jpg" width="23" height="40" border="0" usemap="#Map"> <map name="Map">
<area shape="rect" coords="2,0,34,47" href="cancel.php?name=<?php print $product['ref'] ?>"></map>

Re: shopping cart delete item

Posted: Thu Oct 02, 2014 6:43 am
by Celauran
Wow. I haven't seen an area map used since literally the 90s. That said, it would be helpful to see some of the surrounding code. Have you confirmed that cancel.php is working correctly? Tried it with both good values and bad?

Re: shopping cart delete item

Posted: Thu Oct 02, 2014 8:06 am
by terrenuit
@Celauran
yes, the cancel.php work correctly, but only for one item,
if there's serveral items, and I want to cancel the last or second last item, it is the first item has been cancelled.

<td align="center"><?php print $product['ref'] ?></td>
<td><?php print $product['price'] ?>€</td>
<td align="center"><?php print $product['quantity'] ?></td>
<td align="center"><?php print($product['quantity']*$produit['prix'])?>€</td>
<td align="center" > <img src="photos/garbage.jpg" width="23" height="40" border="0" usemap="#Map"> <map name="Map">
<area shape="rect" coords="2,0,34,47" href="cancel.php?ref=<?php print $product['ref'] ?>"></map>
</td>

Re: shopping cart delete item

Posted: Thu Oct 02, 2014 8:17 am
by Celauran

Code: Select all

<td align="center"><?php print $product['ref'] ?></td>
<td><?php print $product['price'] ?>€</td>
<td align="center"><?php print $product['quantity'] ?></td>	
<td align="center"><?php print($product['quantity']*$produit['prix'])?>€</td>	
<td align="center" > <img src="photos/garbage.jpg" width="23" height="40" border="0" usemap="#Map"> <map name="Map">
<area shape="rect" coords="2,0,34,47" href="cancel.php?ref=<?php print $product['ref'] ?>"></map> 
</td>
This is being executed within a loop? It looks correct at a glance, but it's hard to say for certain. I suspect cancel.php is where the problem lies, especially when you say things like this:
terrenuit wrote:yes, the cancel.php work correctly, but only for one item,

Re: shopping cart delete item

Posted: Thu Oct 02, 2014 11:27 am
by terrenuit
if I replace
<td align="center" > <img src="photos/garbage.jpg" width="23" height="40" border="0" usemap="#Map"> <map name="Map">
<area shape="rect" coords="2,0,34,47" href="cancel.php?ref=<?php print $product['ref'] ?>"></map>

by
<td> <a href="supprimer.php?ref=<?php print $product['ref'] ?>">cancel</a></td>
it is all right, I can cancel the item as I want,
so, I d'ont understand why ?

Re: shopping cart delete item

Posted: Thu Oct 02, 2014 11:32 am
by Celauran
Supprimer.php and cancel.php contain the exact same code?

Re: shopping cart delete item

Posted: Fri Oct 03, 2014 1:43 am
by terrenuit
yes, excuse me I forgot to change it
<td> <a href="cancel.php?ref=<?php print $product['ref'] ?>">cancel</a></td>

Re: shopping cart delete item

Posted: Fri Oct 03, 2014 9:50 am
by borre
Can we see the cancel.php ?

The problem might be right there.

But if you have troubles with using the area map, maybe might consider just using modern coding and forget about the map tags.. :p

Re: shopping cart delete item

Posted: Sat Oct 04, 2014 1:35 am
by terrenuit
yes, it is the cancel.php:
<?php
session_start();
require_once 'panier.php';
$panier = new Panier('produits');
$panier->delete($_GET['name']);

header('location: cart.php');
?>
I prefer the garbage than the word "cancel", because it is more beautiful

Re: shopping cart delete item

Posted: Sat Oct 04, 2014 6:26 am
by Celauran
terrenuit wrote:I prefer the garbage than the word "cancel", because it is more beautiful
You can certainly use an image in a link without resorting to an image map. Bootstrap's glyph icons, FontAwesome, etc. Plus just regular old images.

Re: shopping cart delete item

Posted: Sat Oct 04, 2014 6:30 am
by Celauran

Code: Select all

href="cancel.php?ref=<?php print $product['ref'] ?>"
but then

Code: Select all

$panier->delete($_GET['name']);
You've got 'ref' in one place and 'name' in another. That's definitely a problem.

Re: shopping cart delete item

Posted: Sat Oct 04, 2014 7:37 am
by terrenuit
yes, you are right, if I put

$panier->delete($_GET['ref']);
my site works correctly,
but If I put the picture( garbage), it doesn't work. I d'ont understand why I cannot replace the word " cancel" by the picture ?

<td align="center" > <img src="photos/garbage.jpg" width="23" height="40" border="0" usemap="#Map"> <map name="Map">
<area shape="rect" coords="2,0,34,47" href="cancel.php?ref=<?php print $product['ref'] ?>"></map>

Re: shopping cart delete item

Posted: Sat Oct 04, 2014 7:48 am
by Celauran

Code: Select all

<a href="cancel.php?ref=<?= $product['ref']; ?>"><img src="photos/garbage.jpg"></a>
That doesn't work?