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.
50 100 200 300 400 500 1000
2000 3000 4000 5000 10000
@cryptokraze | @arie.steem | @qasimwaqar | @vvarishayy | @suboohi
https://steemit.com/hive-172186/@alimurtawza/achievement-3-posted-by-alimurtawza-content-etiquette
Mam please verify my achievement
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@ghulfam/achievement1-introduction-myself-by-ghulfam
Please verify my post
@vvarishayy
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Mam @vvarishayy
plz verify my achievement 1
https://steemit.com/hive-172186/@fasalnawaz/achievement-1-by-fasalnawaz-or-or-my-introduction-post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Plz verify my Achievement 2
Achievement2 Basic security on steemit by @huzaiz1(19/10/2021)
It is going to expiring
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Mam please verify my Achievement 5.1
Achievement 5 Task 1 //Review steemworld.org by @azanalisial
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Plz lable me varified
https://steemit.com/hive-172186/@amjadnawaz/4tnj1z-achievement2-basic-security-by-amjadnawaz
@vvarishayy
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@ijazhussain09/4m5yxb-achievement-3-by-ijazhussain09-or-or-content-etiquette
Dear @vvarishayy
plz verify my achievement 3
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Mam @vvarishayy
kindly verify my achievement 3
https://steemit.com/hive-172186/@jahangeer07/6ncv5q-achievement-3-by-jahangeer07-or-or-content-etiquette
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Verify plz @vvarishayy
https://steemit.com/hive-172186/@atifahmad3045/5kzcvi-achievement-2-or-or-basic-security-by-atifahmad3045
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@aliasghar9090/achievement-2-basic-security-on-steemit-aliasghar9090-25-10-2021
Mam Please verify my achievment
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
You forgot to switch the account. It's suspecious, you're saying to verify your account and the achievement is of someone's else.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@aliakbarnaik/achievement-5-task-steem-world-tool-1-by-aliakbarnaik-23-10-2021
Mam please verify my Achievement
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@alimurtawza/achievement-3-posted-by-alimurtawza-content-etiquette
Mam @vvarishayy Please verify this
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
deleted
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@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
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@saju2090/achievement-2-basic-security-on-steemit-saju2090-26-10-2021
Mam please verify my Achievement
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good one tutorial.....
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Mam @vvarishayy plz verify my Achievement
https://steemit.com/hive-172186/@alihaider1/achievement-5-task-1-or-or-review-steemworld-org-by-alihaider1
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@sonybhai/achievement-1-introduction-to-myself-by-sonybhai
Please verify achi1 @vvarishayy
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Please verify the steemit in Pakistan username @aslam234
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@arfan11/4dyz8f-achievement-5-task-2-steemscan-com-arfan11
Please verify @vvarishayy kindly request ma'am
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@telenor6168/achievement2-basic-sucurity-by-telenor6168
Plase verify.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@ranashumiaz/4bmcym-achievement-4-task-applying-markdown-method-by-ranashumiaz
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
#club5050 😀
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@mnadeem8/achievement-1-introduction-to-myself-by-mnadeem8
Please verify achievement 1
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@alihassnain1/achievement2-task-basic-security-by-alihassnain1
Plz verify my post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@vvarishayy https://steemit.com/hive-172186/@mnadeem8/achievement-1-introduction-to-myself-by-mnadeem8
Please verify my achievement 1 @vvarishayy
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@ahmad78/or-or-achievement-1-or-or-introduction-to-myself-post-by-or-or-ahmad78-30-10-2021-or-or
Verify please 🥺🥺
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Sorry Mam for disturbing but it was going expired
Achievement
Plz verify
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
https://steemit.com/hive-172186/@mnadeem8/achievement-1-introduction-to-myself-by-mnadeem8
Please verify @vvarishayy
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit