E-commerce Cart Using OOPS
Team Members:- Guided By:-
• Akarsh Raj Mr. Gurpreet Singh
(23SECE1290160)
• Shubham
(23SECE1290122)
SECTION - 43
Name of the School: School of Computer Science and Engineering
Course Code: E2UC201C Course Name: OOPS
Content
Name of the School: School of Computer Science and Engineering
Course Code: E2UC201C Course Name: OOPS
• Problem Statement
• Code
• Flow Chart
• Technology Used
• Conclusion
Problem Statement
• In today's digital age, businesses are increasingly turning to e-commerce as a means of
reaching a wider customer base and offering convenient shopping experiences.
• Small to medium-sized businesses, particularly those in retail, are keen to establish an
online presence to remain competitive and cater to changing consumer preferences.
• The need arises for a robust e-commerce shopping cart system that can seamlessly
integrate with existing websites or standalone platforms, allowing businesses to showcase
and sell their products online.
• An E-commerce shopping cart is a software that lets customers select, store, and manage
items before buying them.
• It allows users to add, remove, and manage items for purchase, calculates total costs,
handles discounts or promotional offers, and provides a seamless checkout experience.
Name of the School: School of Computer Science and Engineering
Course Code: E2UC201C Course Name: OOPS
Code - Create the Product Class
class Product:
def __init__(self, id, name, price, description=''):
self.id = id
self.name = name
self.price = price
self.description = description
def __str__(self):
return f"{self.name} - ${self.price}"
Name of the School: School of Computer Science and Engineering
Course Code: E2UC201C Course Name: OOPS
Code - Create the Cartless Class
class CartItem:
def __init__(self, product, quantity):
self.product = product
self.quantity = quantity
def increase_quantity(self, amount=1):
self.quantity += amount
def decrease_quantity(self, amount=1):
self.quantity -= amount
if self.quantity < 0:
self.quantity = 0
def get_total_price(self):
return self.product.price * self.quantity
def __str__(self):
return f"{self.product.name} x {self.quantity} = ${self.get_total_price()}"
Name of the School: School of Computer Science and Engineering
Course Code: E2UC201C Course Name: OOPS
Code - Create the Shopping Cart Class
class ShoppingCart:
def __init__(self):
self.items = {}
def add_product(self, product, quantity=1):
if product.id in self.items:
self.items[product.id].increase_quantity(quantity)
else:
self.items[product.id] = CartItem(product, quantity)
def remove_product(self, product_id, quantity=1):
if product_id in self.items:
self.items[product_id].decrease_quantity(quantity)
if self.items[product_id].quantity == 0:
del self.items[product_id]
def get_total(self):
return sum(item.get_total_price() for item in self.items.values())
def __str__(self):
cart_contents = 'n'.join(str(item) for item in self.items.values())
return f"Shopping Cart:n{cart_contents}nTotal: ${self.get_total()}"
Name of the School: School of Computer Science and Engineering
Course Code: E2UC201C Course Name: OOPS
Code – Example Usage
# Create some products
apple = Product(id=1, name="Apple", price=0.50, description="Red Apple")
bread = Product(id=2, name="Bread", price=1.50, description="Whole
wheat")
# Create a shopping cart
cart = ShoppingCart()
# Add products to the cart
cart.add_product(apple, 3)
cart.add_product(bread, 1)
print(cart)
# Remove a product
cart.remove_product(1, 1)
print(cart)
Name of the School: School of Computer Science and Engineering
Course Code: E2UC201C Course Name: OOPS
Flowchart
Name of the School: School of Computer Science and Engineering
Course Code: E2UC201C Course Name: OOPS
Start
Customer
Purchase Product
NO
Product
Scanning
Procedure
Display the Details of items
Yes
Checkout
End
Technology Used
Programming Language:
Python - Chosen for its versatility, readability, and extensive support for web
development frameworks. Python offers a rich ecosystem of libraries and tools
that streamline the development process. Its syntax is clean and intuitive,
making it ideal for implementing complex functionalities with ease.
IDLE is an integrated development environment for Python, which has been
bundled with the default implementation of the language since 1.5.2b1. It is
packaged as an optional part of the Python packaging with many Linux
distributions. It is completely written in Python.
Name of the School: School of Computer Science and Engineering
Course Code: E2UC201C Course Name: OOPS
Name of the School: School of Computer Science and Engineering
Course Code: E2UC201C Course Name: OOPS
• E-commerce still represents one of the business methods that take advantage if done the
right way, even if the stock market and commodities fell, but E-Commerce still able to
survive and receive high transaction.
• India's e-commerce sector has a positive cascading effect on other industries by directly
influencing small and medium enterprises (MSMEs), providing funding, technology, and
training.
• The primary Objective of E-Commerce Cart is to reach maximum customers at the right
time and place to enhance sales and profitability of the business.
CONCLUSION
Name of the School: School of Computer Science and Engineering
Course Code: E2UC201C Course Name: OOPS
THANK YOU

E-commerce cart using oops in Python.pptx

  • 1.
    E-commerce Cart UsingOOPS Team Members:- Guided By:- • Akarsh Raj Mr. Gurpreet Singh (23SECE1290160) • Shubham (23SECE1290122) SECTION - 43 Name of the School: School of Computer Science and Engineering Course Code: E2UC201C Course Name: OOPS
  • 2.
    Content Name of theSchool: School of Computer Science and Engineering Course Code: E2UC201C Course Name: OOPS • Problem Statement • Code • Flow Chart • Technology Used • Conclusion
  • 3.
    Problem Statement • Intoday's digital age, businesses are increasingly turning to e-commerce as a means of reaching a wider customer base and offering convenient shopping experiences. • Small to medium-sized businesses, particularly those in retail, are keen to establish an online presence to remain competitive and cater to changing consumer preferences. • The need arises for a robust e-commerce shopping cart system that can seamlessly integrate with existing websites or standalone platforms, allowing businesses to showcase and sell their products online. • An E-commerce shopping cart is a software that lets customers select, store, and manage items before buying them. • It allows users to add, remove, and manage items for purchase, calculates total costs, handles discounts or promotional offers, and provides a seamless checkout experience. Name of the School: School of Computer Science and Engineering Course Code: E2UC201C Course Name: OOPS
  • 4.
    Code - Createthe Product Class class Product: def __init__(self, id, name, price, description=''): self.id = id self.name = name self.price = price self.description = description def __str__(self): return f"{self.name} - ${self.price}" Name of the School: School of Computer Science and Engineering Course Code: E2UC201C Course Name: OOPS
  • 5.
    Code - Createthe Cartless Class class CartItem: def __init__(self, product, quantity): self.product = product self.quantity = quantity def increase_quantity(self, amount=1): self.quantity += amount def decrease_quantity(self, amount=1): self.quantity -= amount if self.quantity < 0: self.quantity = 0 def get_total_price(self): return self.product.price * self.quantity def __str__(self): return f"{self.product.name} x {self.quantity} = ${self.get_total_price()}" Name of the School: School of Computer Science and Engineering Course Code: E2UC201C Course Name: OOPS
  • 6.
    Code - Createthe Shopping Cart Class class ShoppingCart: def __init__(self): self.items = {} def add_product(self, product, quantity=1): if product.id in self.items: self.items[product.id].increase_quantity(quantity) else: self.items[product.id] = CartItem(product, quantity) def remove_product(self, product_id, quantity=1): if product_id in self.items: self.items[product_id].decrease_quantity(quantity) if self.items[product_id].quantity == 0: del self.items[product_id] def get_total(self): return sum(item.get_total_price() for item in self.items.values()) def __str__(self): cart_contents = 'n'.join(str(item) for item in self.items.values()) return f"Shopping Cart:n{cart_contents}nTotal: ${self.get_total()}" Name of the School: School of Computer Science and Engineering Course Code: E2UC201C Course Name: OOPS
  • 7.
    Code – ExampleUsage # Create some products apple = Product(id=1, name="Apple", price=0.50, description="Red Apple") bread = Product(id=2, name="Bread", price=1.50, description="Whole wheat") # Create a shopping cart cart = ShoppingCart() # Add products to the cart cart.add_product(apple, 3) cart.add_product(bread, 1) print(cart) # Remove a product cart.remove_product(1, 1) print(cart) Name of the School: School of Computer Science and Engineering Course Code: E2UC201C Course Name: OOPS
  • 8.
    Flowchart Name of theSchool: School of Computer Science and Engineering Course Code: E2UC201C Course Name: OOPS Start Customer Purchase Product NO Product Scanning Procedure Display the Details of items Yes Checkout End
  • 9.
    Technology Used Programming Language: Python- Chosen for its versatility, readability, and extensive support for web development frameworks. Python offers a rich ecosystem of libraries and tools that streamline the development process. Its syntax is clean and intuitive, making it ideal for implementing complex functionalities with ease. IDLE is an integrated development environment for Python, which has been bundled with the default implementation of the language since 1.5.2b1. It is packaged as an optional part of the Python packaging with many Linux distributions. It is completely written in Python. Name of the School: School of Computer Science and Engineering Course Code: E2UC201C Course Name: OOPS
  • 10.
    Name of theSchool: School of Computer Science and Engineering Course Code: E2UC201C Course Name: OOPS • E-commerce still represents one of the business methods that take advantage if done the right way, even if the stock market and commodities fell, but E-Commerce still able to survive and receive high transaction. • India's e-commerce sector has a positive cascading effect on other industries by directly influencing small and medium enterprises (MSMEs), providing funding, technology, and training. • The primary Objective of E-Commerce Cart is to reach maximum customers at the right time and place to enhance sales and profitability of the business. CONCLUSION
  • 11.
    Name of theSchool: School of Computer Science and Engineering Course Code: E2UC201C Course Name: OOPS THANK YOU