Omjeemishra1 commited on
Commit
e99cffb
·
verified ·
1 Parent(s): 5924696

Upload utils.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. utils.py +10 -127
utils.py CHANGED
@@ -1,150 +1,33 @@
1
  import pandas as pd
2
  import streamlit as st
3
 
4
- # Mock Product Data
5
  PRODUCT_DATA = [
6
  {
7
  "id": 1,
8
  "name": "Wireless Headphones Pro",
9
  "category": "Electronics",
10
  "price": 199.99,
 
11
  "image": "https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=400&h=300&fit=crop",
12
- "description": "Premium wireless headphones with noise cancellation"
 
 
13
  },
14
  {
15
  "id": 2,
16
  "name": "Smart Watch Series X",
17
  "category": "Electronics",
18
  "price": 349.99,
 
19
  "image": "https://images.unsplash.com/photo-1523275335684-37898b6baf30?w=400&h=300&fit=crop",
20
- "description": "Advanced fitness tracking and smart notifications"
 
 
21
  },
22
  {
23
  "id": 3,
24
  "name": "Leather Luxury Bag",
25
  "category": "Fashion",
26
  "price": 159.99,
27
- "image": "https://images.unsplash.com/photo-1548036328-c9fa89d128fa?w=400&h=300&fit=crop",
28
- "description": "Handcrafted genuine leather bag"
29
- },
30
- {
31
- "id": 4,
32
- "name": "Running Shoes Ultra",
33
- "category": "Sports",
34
- "price": 129.99,
35
- "image": "https://images.unsplash.com/photo-1542291026-7eec264c27ff?w=400&h=300&fit=crop",
36
- "description": "Lightweight performance running shoes"
37
- },
38
- {
39
- "id": 5,
40
- "name": "Minimalist Desk Lamp",
41
- "category": "Home",
42
- "price": 79.99,
43
- "image": "https://images.unsplash.com/photo-1507473885765-e6ed057f782c?w=400&h=300&fit=crop",
44
- "description": "Modern LED desk lamp with adjustable brightness"
45
- },
46
- {
47
- "id": 6,
48
- "name": "Organic Coffee Beans",
49
- "category": "Food",
50
- "price": 24.99,
51
- "image": "https://images.unsplash.com/photo-1559056199-641a0ac8b55e?w=400&h=300&fit=crop",
52
- "description": "Premium organic arabica coffee beans (1kg)"
53
- },
54
- {
55
- "id": 7,
56
- "name": "Bluetooth Speaker",
57
- "category": "Electronics",
58
- "price": 89.99,
59
- "image": "https://images.unsplash.com/photo-1608043152269-423dbba4e7e1?w=400&h=300&fit=crop",
60
- "description": "Portable waterproof speaker with 20h battery"
61
- },
62
- {
63
- "id": 8,
64
- "name": "Yoga Mat Premium",
65
- "category": "Sports",
66
- "price": 45.99,
67
- "image": "https://images.unsplash.com/photo-1601925260368-ae2f83cf8b7f?w=400&h=300&fit=crop",
68
- "description": "Extra thick eco-friendly yoga mat"
69
- },
70
- {
71
- "id": 9,
72
- "name": "Sunglasses Classic",
73
- "category": "Fashion",
74
- "price": 149.99,
75
- "image": "https://images.unsplash.com/photo-1572635196237-14b3f281503f?w=400&h=300&fit=crop",
76
- "description": "Timeless polarized sunglasses"
77
- },
78
- {
79
- "id": 10,
80
- "name": "Plant Pot Set",
81
- "category": "Home",
82
- "price": 39.99,
83
- "image": "https://images.unsplash.com/photo-1485955900006-10f4d324d411?w=400&h=300&fit=crop",
84
- "description": "Set of 3 ceramic plant pots"
85
- },
86
- {
87
- "id": 11,
88
- "name": "Wireless Charger",
89
- "category": "Electronics",
90
- "price": 34.99,
91
- "image": "https://images.unsplash.com/photo-1586816879360-004f5b0c51e5?w=400&h=300&fit=crop",
92
- "description": "Fast wireless charging pad for all devices"
93
- },
94
- {
95
- "id": 12,
96
- "name": "Backpack Urban",
97
- "category": "Fashion",
98
- "price": 69.99,
99
- "image": "https://images.unsplash.com/photo-1553062407-98eeb64c6a62?w=400&h=300&fit=crop",
100
- "description": "Water-resistant urban backpack with laptop compartment"
101
- }
102
- ]
103
-
104
- @st.cache_data
105
- def load_products():
106
- """Load product data as a DataFrame."""
107
- return pd.DataFrame(PRODUCT_DATA)
108
-
109
- def format_currency(amount):
110
- """Format amount as currency."""
111
- return f"${amount:,.2f}"
112
-
113
- def add_to_cart(product):
114
- """Add a product to the cart."""
115
- cart = st.session_state.cart
116
-
117
- # Check if product already exists in cart
118
- for item in cart:
119
- if item['id'] == product['id']:
120
- item['quantity'] += 1
121
- return
122
-
123
- # Add new item to cart
124
- cart_item = {
125
- 'id': product['id'],
126
- 'name': product['name'],
127
- 'price': product['price'],
128
- 'quantity': 1
129
- }
130
- cart.append(cart_item)
131
-
132
- def remove_from_cart(product_id):
133
- """Remove a product from the cart."""
134
- cart = st.session_state.cart
135
- cart = [item for item in cart if item['id'] != product_id]
136
- st.session_state.cart = cart
137
-
138
- def get_cart_total():
139
- """Calculate the total price of items in the cart."""
140
- total = 0
141
- for item in st.session_state.cart:
142
- total += item['price'] * item['quantity']
143
- return total
144
-
145
- def get_cart_count():
146
- """Get the total number of items in the cart."""
147
- count = 0
148
- for item in st.session_state.cart:
149
- count += item['quantity']
150
- return count
 
1
  import pandas as pd
2
  import streamlit as st
3
 
4
+ # Enhanced Product Data with ratings and original prices
5
  PRODUCT_DATA = [
6
  {
7
  "id": 1,
8
  "name": "Wireless Headphones Pro",
9
  "category": "Electronics",
10
  "price": 199.99,
11
+ "original_price": 249.99,
12
  "image": "https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=400&h=300&fit=crop",
13
+ "description": "Experience crystal-clear audio with our premium wireless headphones. Features active noise cancellation, 30-hour battery life, and ultra-comfortable ear cushions for all-day wear.",
14
+ "rating": 5,
15
+ "reviews": 1247
16
  },
17
  {
18
  "id": 2,
19
  "name": "Smart Watch Series X",
20
  "category": "Electronics",
21
  "price": 349.99,
22
+ "original_price": 449.99,
23
  "image": "https://images.unsplash.com/photo-1523275335684-37898b6baf30?w=400&h=300&fit=crop",
24
+ "description": "Stay connected and track your fitness goals with the advanced Smart Watch Series X. Features heart rate monitoring, GPS, and smart notifications.",
25
+ "rating": 5,
26
+ "reviews": 892
27
  },
28
  {
29
  "id": 3,
30
  "name": "Leather Luxury Bag",
31
  "category": "Fashion",
32
  "price": 159.99,
33
+ "original_price":