Answer the question
In order to leave comments, you need to log in
How to add an item to the cart?
Hello everyone, I would like to know how you can add an item to the cart. The bot has a carousel of products and an "Add to Cart" button. Here is the question - how to make it clear to the bot on which product the user is in this carousel, so that by clicking on this button, the product data goes to the database? Aiogram library.
async def ecuador(call:types.CallbackQuery):
kb = InlineKeyboardMarkup(row_width=2)
next = InlineKeyboardButton(text= 'Следующий',callback_data= 'next_1')
previous = InlineKeyboardButton(text= 'Предыдущий',callback_data= 'previous_1')
add = InlineKeyboardButton(text= 'Добавить в корзину',callback_data= 'add')
kb.add(previous,next,add)
back = InlineKeyboardButton(text= 'Назад',callback_data= 'back')
kb.add(back)
await bot.send_photo(
chatId,
photo = current_photo,
caption='Название: '+ current_item +'\n\nЦена: '+ current_price,
reply_markup=kb)
Answer the question
In order to leave comments, you need to log in
Add some product ID to callback_data
. Let's say your products have an ID
# допустим, текущий товар имеет id 1058
add = InlineKeyboardButton(text= 'Добавить в корзину',callback_data= 'add_1058')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question