DEV Community

notfromearth
notfromearth

Posted on

Hi I'm new here.

Hello guys i saw dev, while I'm researching about looking for collaboration, this site is really great i hope i can find a workmates here. Hit me up if u are interested in E-commerce i have this idea but i don't know how to start, thanks!

Top comments (2)

Collapse
 
cmuralisree profile image
Chittoji Murali Sree Krishna • Edited

To build any stuff like ecommerce, you have to make a plan first

Step1: always make note what you have done,
Step2: make user validation and stuff, store users in database && also make sure the username or email is unique from eachother
Step3: create a database and create a table for products values of table like name, image, desc, price.... And render it in home page
Step4: then validating the buttons like for example on click of add to cart it should add to the cart of that particular item you can use the product_id here for that so each product have different id numbers so onclick add the product_id & particular username to another table in the database,
Ex with PHP:

$query = "SELECT * FROM products";
$results = mysqli_query($db, $query);
Foreach($results as $result){
<Form type="POST">
<Input type="hidden" value="<?php echo $result['id']; ?>">
// I am taking the I'd bcz each and every product will have its own I'd bcz it's auto incremented on upload
<Button type="submit">Add to cart
</Form>
$user = $_SESSION['username'];
$product_id = $_POST['id'];
$query = "INSERT INTO cart (id, product_id, username) VALUES ('$product_id', '$user')";
Step5: check wether those values uploaded to the table, if they are uploaded then go for the cart page,
Step6: cart page first gather the data using those values like in PHP $query ="SELECT * FROM cart WHERE `username`='$_SESSION['username']'";
$results = mysqli_query($db, $query);
Foreach ($results as $result){
$id = $result['product_id'];
$query2 = "SELECT * FROM products WHERE `id`='$id'";
$products = mysqli_query($db, $query);
Foreach($products as $product){
echo "<h1>$product['name']</h1>";
echo "<img src='$product['image']'>";
echo "<p>$product['price']</p>";
}
}
Enter fullscreen mode Exit fullscreen mode

This will render all the items which were present in the cart,
Step7: add options to increase or decrease the items in the cart if less than one remove the column from the table if it's more than 1 add column and make sure only the count and price must be doubled insted of displaying it as another item on screen,

Step8: now it's a checkout page where all the selected products price will be displayed and Have a payment options like card or cash on delivery ..., Then address part it can be saved to a new table in the database or no, but once after the checkout button is clicked then all the products_ids in cart page where it links to username or email must be deleted so that he doesn't see old items in the cart

Collapse
 
peace_221998 profile image
notfromearth

Hello that's awesome ๐Ÿ˜Š to be honest i don't have any skills about web development, i like the system, i followed u on Instagram ๐Ÿ˜Š thank u!