Siz tutorial - Online shopping cart (part 2)

in hive-181430 •  3 years ago 


Hey steemit people!!

Hope you're fine and doing well here and as well as in your personal life. It's been a while I haven't shared anything or any tutorial with you. Today I am discussing the project that I made recently that was an online shopping cart. The project is made using the python language and completely on CLI. In this post, I will be covering only the class of all products and class of add to cart method while another or remaining portions of this project will be discussed in another post as a continuation. You won't get the code this way because I made a file named function where the functions are saved and I am recalling the functions from that file in the entire code. Stay tuned for the complete project.


PROBLEM DESCRIPTION:

Online shopping cart is a virtual shopping trolley, where shoppers can put all of
their want-to-buy products in, review to make adjustments in quantity, product
attributes, etc., and remove it before or during the checkout if they change their
mind.

FEATURES OF OUR SHOPPING CART:

• We used database SQLite which helps in maintaining the records easily and properly as
well.
• It has permanent storage of the users.
• Our shopping cart displays the products.
• It can export from cart.
• You can delete the items that you don’t want from cart.
• You can delete the history.
• It displays the entire history as well along with the time.

FILES IMPORTED

import functions
from datetime import datetime
import sys
import time
from abc import ABC, abstractmethod

CLASS ALL_PRODUCTS:

We have assigned all the products with a unique code. And search that code in the saved
products. If found any then proceed with that product and if not then shows an appropriate
message.



class all_product:
 def pick(self):
 print("PICK PRODUCT BY CODE: ")
 try:
 self.choice=input("ENTER CODE: ")
9
 flag=0
 for i in self.all:
 if i[0] == self.choice:
 print(i)
 print(flag)
 self.item_lst = i
 flag = 1

 if flag == 0:
 raise ValueError
 else:
 print("MOVING PRODUCT TO CART: ")
 c=add_to_cart()
 c.store_in_cart(self.item_lst)
 except ValueError:
 print("ENTER CORRECT CODE")
 self.pick()
 def __init__(self):
 elements=self.all=functions.show_all("user.db","product")
 for element in elements:
 print(element)
 self.pick()


CLASS ADD_TO_CART:

If the user selected the option of add to cart, then this will add the products to the cart. It will
update the database and add the selected items to the list. It stores the data as well.


class add_to_cart:
 def export(self):
 all_data=functions.show_all("user.db","cart")
 total=0
 lst=[]
 for i in all_data:
 print(i)
 if i[3]==username:
 total+=i[2]
 lst.append(i[1])
10
 print("TOTAL AMOUNT",total)
 s=shopping_history()
 s.add_to_history(total,lst)
 def choice(self):
 print("YOU HAVE MAKE ONE OF THE FOLLOWING : ")
 print("1.export for payment: ")
 print("2.Continue Shopping: ")
 print("3.Exit")
 try:
 self.choice=input("ENTER NUMBER: ")
 if self.choice=="1":
 self.export()
 elif self.choice=="2":
 p=all_product()
 elif self.choice=="3":
 sys.exit()
 else:
 raise ValueError
 except:
 print("ENTER CORRECT VALUE")
 def store_in_cart(self,ele_lst):
 self.lst=ele_lst
 functions.add_one_data("user.db","cart",(self.lst[0],self.lst[1],self.lst
[2],username))
 self.choice()
 def __init__(self)



THANK YOU FOR VISITING
CATCH YOU ON ANOTHER POST!
WITH BEST REGARDS
COUNTRY REPRESENTATIVE PAKISTAN


You can delegate your SP to @siz-official and take benefit of our Delegation Rewards Offer of getting up to 200% Curation Rewards

You can also use these quick delegation links. Just click on the desired amount of SP you want to delegate, and it will be done in the process of 1 minute.

Quick Delegation to SIZ
50 100 200 300 400 500 1000
2000 3000 4000 5000 10000

Divider 2.png

Steem Infinity Zone Team
@cryptokraze | @arie.steem | @qasimwaqar | @vvarishayy | @suboohi

Footer.png

Click Here to Join Official SIZ Discord Channel

Discord
Twitter
Facebook

Divider 2.png

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Plz verify my Achievement 2
Achievement2 Basic security on steemit by @huzaiz1(19/10/2021)
It is going to expiring

You forgot to switch the account. It's suspecious, you're saying to verify your account and the achievement is of someone's else.

deleted

@vvarishayy plz varified my achievement 1 plz plz plz 2 week ago my first achievement post so plz in request you plz varified my achievement 1 thankyou

@vvarishayy

Good one tutorial.....

Please verify the steemit in Pakistan username @aslam234

#club5050 😀

Respected Mam, Aslam o Alikum Mam Maine club5050 join kr Liya hy
Main ajj tak Jo earn kia hy sb Steem ki power up kr raha hun
https://steemit.com/hive-136998/@zohaibb/joining-club5050-or-or-power-up-my-100-earings-of-the-week-or-or-20-payout-goes-to-steemit-pak-or-or-by-zohaibb

Sorry Mam for disturbing but it was going expired
Achievement
Plz verify

Aalamalikam @vvarishayy how are you i hope you doing great 👍 i have one request for you i hope you do this i done my second achievement post so i want you varified it through steemcurators i hope you do it. Thankyou

https://steemit.com/hive-172186/@qazikhizar093/achievement-2-or-or-basic-security-system-of-steemit-or-or-qazikhizar093