Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,179,376 members, 7,908,036 topics. Date: Thursday, 01 August 2024 at 06:13 PM

Trying To Remove Item Fro A Shopping Cart. - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Trying To Remove Item Fro A Shopping Cart. (1500 Views)

How Can I Create A Shopping Cart? / Programming Shopping Cart Issue Wondering How They Do It / Trying To Run Php Project After Installing Wamp Server (2) (3) (4)

(1) (Reply) (Go Down)

Trying To Remove Item Fro A Shopping Cart. by adeyeye546: 10:59am On Oct 09, 2014
<?php
if (isset($_POST['index_to_remove']) && $_POST['index_to_remove'] != ""wink {
// Access the array and run code to remove that array index
// Reomve functionality
$key_to_remove = $_POST['index_to_remove'];// hold array index to that variable and pass it to the local variable

if (count($_SESSION["cart_array"]) <= 1) { // if item greater than one
unset($_SESSION["cart_array"]);
// header("location: cart.php"wink;
} else {
unset($_SESSION["cart_array"]["$key_to_remove"]);//correspond to the cart_item
//sort($_SESSION["cart_array"])
sort($_SESSION["cart_array"]); // sorting of all the multi- dimensional array

};
}
Re: Trying To Remove Item Fro A Shopping Cart. by javadoctor(m): 3:41am On Oct 12, 2014
I don't understand php, but in java you could simply remove the object from a Map
With a key value.

Map <CartItem,Integer>item = new HashMap();
Re: Trying To Remove Item Fro A Shopping Cart. by asalimpo(m): 6:56am On Oct 12, 2014
*Simply use ur hand to remove it and return it to d store shelf!
If ur in a supermarket/mart.

If online use the "remove/delete/save for l8r" button
*

pardon the sakazm but ur question is ripe for misinterpretation.
Re: Trying To Remove Item Fro A Shopping Cart. by Nobody: 9:37am On Oct 12, 2014
javadoctor:
I don't understand php, but in java you could simply remove the object from a Map
With a key value.

Map <CartItem,Integer>item = new HashMap();

True, PHP does the same. @op, just use var_dump($_POST); to get the structure of the array - you can then post it here so we tell you how to remove it - i might not be here, i am hardly here these days. Been building my www.Nairaland.com - and that is taking like all my time.

asalimpo:

*Simply use ur hand to remove it and return it to d store shelf!
If ur in a supermarket/mart.
If online use the "remove/delete/save for l8r" button
*
pardon the sakazm but ur question is ripe for misinterpretation.
That your act is known as thievery and is punishable by life imprisonment.

(1) (Reply)

Help With Java Programing: Changing Motion Of A Particle In A Jpanel / Padding/margin I Need Help / 10 Tech Certifications That Actually Mean Something

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.