17/08/2026
# KABIR STORE SETTINGS
# ==================================================
Window.fullscreen = "auto"
PRODUCT_FILE = "products.json"
ADMIN_FILE = "admin.json"
IMAGE_DIR = "kabir_images"
WHATSAPP = "8801933251482"
# ==================================================
# APP
# ==================================================
class KabirStore(App):
def build(self):
os.makedirs(IMAGE_DIR, exist_ok=True)
self.cart = []
return self.home()
# ==================================================
# BUTTON
# ==================================================
def btn(self, text, height=52):
return Button(
text=text,
font_size=dp(16),
size_hint_y=None,
height=dp(height)
)
# ==================================================
# DATA
# ==================================================
def load_products(self):
if not os.path.exists(PRODUCT_FILE):
return []
try:
with open(
PRODUCT_FILE,
"r",
encoding="utf-8"
) as f:
return json.load(f)
except:
return []
def save_products(self, data):
with open(
PRODUCT_FILE,
"w",
encoding="utf-8"
) as f:
json.dump(
data,
f,
ensure_ascii=False,
indent=2
)
# ==================================================
# HOME
# ==================================================
def home(self):
root = BoxLayout(
orientation="vertical",
padding=dp(8),
spacing=dp(7)
)
# HEADER
header = BoxLayout(
size_hint_y=None,
height=dp(65),
spacing=dp(5)
)
title = Label(
text="KABIR STORE",
font_size=dp(25),
bold=True
)
admin = Button(
text="ADMIN",
size_hint_x=None,
width=dp(90)
)
header.add_widget(title)
header.add_widget(admin)
root.add_widget(header)
admin.bind(
on_press=lambda x:
self.admin_login()
)
# SEARCH
self.search = TextInput(
hint_text="🔍 Search products...",
multiline=False,
font_size=dp(18),
size_hint_y=None,
height=dp(52)
)
root.add_widget(self.search)
self.search.bind(
text=lambda obj, value:
self.show_products(value)
)
# PRODUCTS
scroll = ScrollView()
self.grid = GridLayout(
cols=2,
spacing=dp(8),
padding=dp(5),
size_hint_y=None
)
self.grid.bind(
minimum_height=
self.grid.setter("height")
)
scroll.add_widget(self.grid)
root.add_widget(scroll)
# BOTTOM
bottom = BoxLayout(
size_hint_y=None,
height=dp(60)
)
home_btn = Button(
text="🏠 HOME"
)
cart_btn = Button(
text="🛒 CART"
)
profile_btn = Button(
text="👤 PROFILE"
)
bottom.add_widget(home_btn)
bottom.add_widget(cart_btn)
bottom.add_widget(profile_btn)
cart_btn.bind(
on_press=lambda x:
self.cart_screen()
)
profile_btn.bind(
on_press=lambda x:
self.profile()
)
root.add_widget(bottom)
self.root = root
self.show_products("")
return root
# ==================================================
# PRODUCTS
# ==================================================
def show_products(self, search=""):
self.grid.clear_widgets()
search = search.lower().strip()
for product in self.load_products():
if product.get(
"hidden",
False
):
continue
if search:
if search not in product.get(
"name",
""
).lower():
continue
self.product_card(product)
# ==================================================
# PRODUCT CARD
# ==================================================
def product_card(self, product):
card = BoxLayout(
orientation="vertical",
padding=dp(6),
spacing=dp(4),
size_hint_y=None,
height=dp(270)
)
image_path = product.get(
"image",
""
)
if (
image_path
and
os.path.exists(image_path)
):
picture = Image(
source=image_path,
size_hint_y=None,
height=dp(110)
)
else:
picture = Label(
text="📷\nNO IMAGE",
font_size=dp(15),
size_hint_y=None,
height=dp(110)
)
name = Label(
text=product.get(
"name",
""
),
font_size=dp(17),
bold=True,
size_hint_y=None,
height=dp(35)
)
price = Label(
text="৳ " + str(
product.get(
"price",
0
)
),
font_size=dp(18),
size_hint_y=None,
height=dp(32)
)
if product.get(
"available",
True
):
add = self.btn(
"🛒 ADD TO CART",
48
)
add.bind(
on_press=lambda x,
p=product:
self.add_to_cart(p)
)
else:
add = self.btn(
"UNAVAILABLE",
48
)
add.disabled = True
card.add_widget(picture)
card.add_widget(name)
card.add_widget(price)
card.add_widget(add)
self.grid.add_widget(card)
# ==================================================
# ADD TO CART
# ==================================================
def add_to_cart(self, product):
for item in self.cart:
if item["id"] == product["id"]:
if item["quantity"] < product["stock"]:
item["quantity"] += 1
self.message(
"CART",
product["name"]
+ " cart-এ আছে।"
)
return
self.cart.append({
"id": product["id"],
"name": product["name"],
"price": product["price"],
"quantity": 1,
"stock": product["stock"]
})
self.message(
"SUCCESS",
product["name"]
+ " cart-এ যোগ হয়েছে।"
)
# ==================================================
# CART
# ==================================================
def cart_screen(self):
main = BoxLayout(
orientation="vertical",
spacing=dp(8),
padding=dp(8)
)
scroll = ScrollView()
self.cart_grid = GridLayout(
cols=1,
spacing=dp(8),
size_hint_y=None
)
self.cart_grid.bind(
minimum_height=
self.cart_grid.setter(
"height"
)
)
scroll.add_widget(
self.cart_grid
)
main.add_widget(scroll)
total_box = BoxLayout(
size_hint_y=None,
height=dp(60)
)
self.total_label = Label(
font_size=dp(20),
bold=True
)
total_box.add_widget(
self.total_label
)
main.add_widget(
total_box
)
checkout = self.btn(
"📦 CHECKOUT / WHATSAPP ORDER",
58
)
close = self.btn(
"CLOSE",
50
)
main.add_widget(checkout)
main.add_widget(close)
pop = Popup(
title="🛒 SHOPPING CART",
content=main,
size_hint=(0.96, 0.92)
)
checkout.bind(
on_press=lambda x:
self.checkout(pop)
)
close.bind(
on_press=pop.dismiss
)
self.cart_popup = pop
self.refresh_cart()
pop.open()
# ==================================================
# REFRESH CART
# ==================================================
def refresh_cart(self):
self.cart_grid.clear_widgets()
total = 0
if not self.cart:
self.cart_grid.add_widget(
Label(
text="🛒 Cart Empty",
font_size=dp(21),
size_hint_y=None,
height=dp(70)
)
)
for item in self.cart:
item_total = (
item["price"]
* item["quantity"]
)
total += item_total
row = BoxLayout(
orientation="vertical",
size_hint_y=None,
height=dp(135),
padding=dp(6),
spacing=dp(4)
)
title = Label(
text=(
item["name"]
+ "\n৳ "
+ str(item["price"])
+ " × "
+ str(item["quantity"])
+ " = ৳ "
+ str(item_total)
),
font_size=dp(16),
size_hint_y=None,
height=dp(65)
)
buttons = BoxLayout(
size_hint_y=None,
height=dp(52),
spacing=dp(5)
)
minus = Button(
text="➖"
)
qty = Label(
text=str(
item["quantity"]
),
font_size=dp(19)
)
plus = Button(
text="➕"
)
remove = Button(
text="🗑️ REMOVE"
)
buttons.add_widget(minus)
buttons.add_widget(qty)
buttons.add_widget(plus)
buttons.add_widget(remove)
row.add_widget(title)
row.add_widget(buttons)
minus.bind(
on_press=lambda x,
i=item:
self.decrease_cart(i)
)
plus.bind(
on_press=lambda x,
i=item:
self.increase_cart(i)
)
remove.bind(
on_press=lambda x,
i=item:
self.remove_cart(i)
)
self.cart_grid.add_widget(
row
)
self.total_label.text = (
"TOTAL: ৳ "
+ str(total)
)
# ==================================================
# INCREASE
# ==================================================
def increase_cart(self, item):
if item["quantity"] < item["stock"]:
item["quantity"] += 1
else:
self.message(
"STOCK",
"আর বেশি Stock নেই।"
)
self.refresh_cart()
# ==================================================
# DECREASE
# ==================================================
def decrease_cart(self, item):
if item["quantity"] > 1:
item["quantity"] -= 1
else:
self.cart.remove(item)
self.refresh_cart()
# ==================================================
# REMOVE
# ==================================================
def remove_cart(self, item):
if item in self.cart:
self.cart.remove(item)
self.refresh_cart()
# ==================================================
# CHECKOUT
# ==================================================
def checkout(self, cart_popup):
if not self.cart:
self.message(
"CART",
"আগে Cart-এ Product যোগ করুন।"
)
return
box = BoxLayout(
orientation="vertical",
padding=dp(10),
spacing=dp(8)
)
name = TextInput(
hint_text="Customer Name",
multiline=False
)
phone = TextInput(
hint_text="Phone Number",
multiline=False
)
address = TextInput(
hint_text="Address / Location"
)
send = self.btn(
"📲 SEND ORDER TO WHATSAPP",
60
)
box.add_widget(name)
box.add_widget(phone)
box.add_widget(address)
box.add_widget(send)
pop = Popup(
title="📦 CUSTOMER INFORMATION",
content=box,
size_hint=(0.95, 0.7)
)
def send_order(x):
if not name.text.strip():
self.message(
"ERROR",
"Customer Name দিন।"
)
return
if not phone.text.strip():
self.message(
"ERROR",
"Phone Number দিন।"
)
return
total = 0
lines = []
for item in self.cart:
item_total = (
item["price"]
* item["quantity"]
)
total += item_total
lines.append(
item["name"]
+ " × "
+ str(
item["quantity"]
)
+ " = ৳"
+ str(item_total)
)
product_text = "\n".join(
lines
)
message = (
"🛒 KABIR STORE — New Order\n\n"
"Customer Name: "
+ name.text
+ "\n"
"Phone: "
+ phone.text
+ "\n"
"Address/Location: "
+ address.text
+ "\n\n"
"PRODUCTS:\n"
+ product_text
+ "\n\n"
"TOTAL: ৳"
+ str(total)
)
url = (
"https://wa.me/"
+ WHATSAPP
+ "?text="
+ quote(message)
)
pop.dismiss()
cart_popup.dismiss()
webbrowser.open(url)
send.bind(
on_press=send_order
)
pop.open()
# ==================================================
# ADMIN LOGIN
# ==================================================
def admin_login(self):
box = BoxLayout(
orientation="vertical",
padding=dp(12),
spacing=dp(8)
)
username = TextInput(
hint_text="Admin Username",
multiline=False
)
password = TextInput(
hint_text="Admin Password",
password=True,
multiline=False
)
login = self.btn(
"🔐 LOGIN"
)
register = self.btn(
"CREATE ADMIN"
)
box.add_widget(username)
box.add_widget(password)
box.add_widget(login)
box.add_widget(register)
pop = Popup(
title="ADMIN LOGIN",
content=box,
size_hint=(0.9, 0.7)
)
def login_now(x):
if not os.path.exists(
ADMIN_FILE
):
self.message(
"ERROR",
"আগে CREATE ADMIN করুন।"
)
return
try:
with open(
ADMIN_FILE,
"r",
encoding="utf-8"
) as f:
data = json.load(f)
if (
username.text
== data["username"]
and
password.text
== data["password"]
):
pop.dismiss()
self.admin_panel()
else:
self.message(
"ERROR",
"Username অথবা Password ভুল।"
)
except:
self.message(
"ERROR",
"Admin data error."
)
login.bind(
on_press=login_now
)
register.bind(
on_press=lambda x:
self.admin_register()
)
pop.open()
# ==================================================
# ADMIN REGISTER
# ==================================================
def admin_register(self):
box = BoxLayout(
orientation="vertical",
padding=dp(10),
spacing=dp(8)
)
username = TextInput(
hint_text="Username",
multiline=False
)
password = TextInput(
hint_text="Password",
password=True,
multiline=False
)
confirm = TextInput(
hint_text="Confirm Password",
password=True,
multiline=False
)
create = self.btn(
"CREATE ACCOUNT"
)
box.add_widget(username)
box.add_widget(password)
box.add_widget(confirm)
box.add_widget(create)
pop = Popup(
title="ADMIN REGISTRATION",
content=box,
size_hint=(0.9, 0.75)
)
def create_now(x):
if len(username.text) < 3:
self.message(
"ERROR",
"Username
)
return
if len(password.text) < 4:
self.message(
"ERROR",
"Password
)
return
if password.text != confirm.text:
self.message(
"ERROR",
"Password
)
return
data = {
"username": username.text,
"password": password.text
}
with open(
ADMIN_FILE,
"w",
encoding="utf-8"
) as f:
json.dump(data, f)
pop.dismiss()