Ejemplo n.º 1
0
def cart(bot, update, args):
    # Function to review all products and quantity by Cart id #
    try:
        cart_id = args[0]
        cartitems = (CartItem.select().join(Cart).where(Cart.id == cart_id))
        cartitems = ', '.join([str(cartitem) for cartitem in cartitems])
        quantities = (CartItem.select().join(Cart).where(Cart.id == cart_id))
        quantities = ', '.join(
            [str(quantity.quantity) for quantity in quantities])
        bot.send_message(
            chat_id=update.message.chat_id,
            text='Your Cart includes the following products: {} '
            'in quantities: {} respectively. '
            '\nIf you want to continue shopping, please use /guidance'
            '\nIf you want to know Your Cart Amount, please use /buy'.format(
                cartitems, quantities))
    except IndexError:
        bot.send_message(chat_id=update.message.chat_id,
                         text='Please use proper format: '
                         '/cart Your Cart # ')