# 3 level
@dp.callback_query_handler(lambda call: call.data.startswith('categ_id'))
async def print_products(call: types.CallbackQuery):
pr_id = call.data[9:]
print(pr_id)
product = db.print_products(pr_id)
product_name = '<b> Название: </b>'
product_price = '<b> Цена: </b>'
product_text = '{product_name_f} {name}\n{product_price_f} <code>{price}</code>'.format(product_name_f = product_name,
name = product[2], product_price_f = product_price, price = product[3])
await bot.send_message(call.from_user.id, product_text, parse_mode='HTML', reply_markup=btn.products_buttons())
await bot.delete_message(call.from_user.id, call.message.message_id)
await bot.answer_callback_query(call.id)
Кнопки:
def products_buttons():
btn_incr = InlineKeyboardButton('-', callback_data='decr')
btn_decr = InlineKeyboardButton('+', callback_data='incr')
#btn_addcart = InlineKeyboardButton('В корзину', callback_data='addcart' + str(pr_id))
btn_back_product = InlineKeyboardButton('Назад', callback_data='back_product')
markup_product = InlineKeyboardMarkup().row(btn_incr, btn_decr) # add '+' and '-'
#markup_product.row(btn_addcart) # add to cart
markup_product.row(btn_back_product) # add back and cart
return markup_product