Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -344,24 +344,62 @@ def cart(): | |
| 344 | 
             
                    else:
         | 
| 345 | 
             
                        coupons = []
         | 
| 346 |  | 
| 347 | 
            -
                    #  | 
| 348 | 
            -
             | 
| 349 | 
            -
             | 
| 350 | 
            -
             | 
| 351 | 
            -
                    )
         | 
| 352 |  | 
| 353 | 
             
                    suggestions = []
         | 
| 354 | 
            -
             | 
| 355 | 
            -
             | 
| 356 | 
            -
             | 
| 357 | 
            -
             | 
| 358 | 
            -
             | 
| 359 | 
            -
             | 
| 360 | 
            -
             | 
| 361 | 
            -
             | 
| 362 | 
            -
             | 
| 363 | 
            -
             | 
| 364 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 365 |  | 
| 366 | 
             
                    return render_template(
         | 
| 367 | 
             
                        "cart.html",
         | 
|  | |
| 344 | 
             
                    else:
         | 
| 345 | 
             
                        coupons = []
         | 
| 346 |  | 
| 347 | 
            +
                    # Inside your /cart route:
         | 
| 348 | 
            +
             | 
| 349 | 
            +
                    category = request.args.get('category', 'All')  # Get the category (default is 'All')
         | 
| 350 | 
            +
                    section = request.args.get('section', 'Biryanis')  # Get the section (default is 'Biryanis')
         | 
|  | |
| 351 |  | 
| 352 | 
             
                    suggestions = []
         | 
| 353 | 
            +
             | 
| 354 | 
            +
                    # Determine the category filter (Veg/Non veg/All)
         | 
| 355 | 
            +
                    if category == 'Veg':
         | 
| 356 | 
            +
                        category_filter = "Veg"
         | 
| 357 | 
            +
                    elif category == 'Non veg':
         | 
| 358 | 
            +
                        category_filter = "Non veg"
         | 
| 359 | 
            +
                    else:  # If category is 'All'
         | 
| 360 | 
            +
                        category_filter = "All"
         | 
| 361 | 
            +
             | 
| 362 | 
            +
                    # Define section-to-complementary section mapping
         | 
| 363 | 
            +
                    complementary_sections = {
         | 
| 364 | 
            +
                        'Breads': ['Curries', 'Biryanis', 'Starters'],
         | 
| 365 | 
            +
                        'Biryanis': ['Curries', 'Starters', 'Desserts'],
         | 
| 366 | 
            +
                        'Curries': ['Rice', 'Breads', 'Starters'],
         | 
| 367 | 
            +
                        'Starters': ['Biryanis', 'Curries', 'Desserts'],
         | 
| 368 | 
            +
                        'Desserts': ['Biryanis', 'Curries', 'Soft Drinks'],
         | 
| 369 | 
            +
                        'Soft Drinks': ['Starters', 'Biryanis', 'Curries']
         | 
| 370 | 
            +
                    }
         | 
| 371 | 
            +
             | 
| 372 | 
            +
                    # Get the complementary sections for the selected section
         | 
| 373 | 
            +
                    suggested_sections = complementary_sections.get(section, [])
         | 
| 374 | 
            +
             | 
| 375 | 
            +
                    # Fetch suggestions from the complementary sections
         | 
| 376 | 
            +
                    try:
         | 
| 377 | 
            +
                        # Loop through complementary sections and fetch the relevant items
         | 
| 378 | 
            +
                        for suggested_section in suggested_sections:
         | 
| 379 | 
            +
                            # If category is "All", we can fetch both Veg and Non veg items from the complementary section
         | 
| 380 | 
            +
                            if category_filter == "All":
         | 
| 381 | 
            +
                                query = f"""
         | 
| 382 | 
            +
                                    SELECT Name, Price__c, Image1__c
         | 
| 383 | 
            +
                                    FROM Menu_Item__c
         | 
| 384 | 
            +
                                    WHERE Section__c = '{suggested_section}' 
         | 
| 385 | 
            +
                                    AND (Veg_NonVeg__c = 'Veg' OR Veg_NonVeg__c = 'Non veg')
         | 
| 386 | 
            +
                                    LIMIT 4
         | 
| 387 | 
            +
                                """
         | 
| 388 | 
            +
                            else:
         | 
| 389 | 
            +
                                # Otherwise, fetch only Veg or Non veg items depending on the selected category
         | 
| 390 | 
            +
                                query = f"""
         | 
| 391 | 
            +
                                    SELECT Name, Price__c, Image1__c
         | 
| 392 | 
            +
                                    FROM Menu_Item__c
         | 
| 393 | 
            +
                                    WHERE Section__c = '{suggested_section}' 
         | 
| 394 | 
            +
                                    AND Veg_NonVeg__c = '{category_filter}'
         | 
| 395 | 
            +
                                    LIMIT 4
         | 
| 396 | 
            +
                                """
         | 
| 397 | 
            +
                            suggestion_result = sf.query(query)
         | 
| 398 | 
            +
                            suggestions.extend(suggestion_result.get("records", []))  # Add all suggestions from each section
         | 
| 399 | 
            +
             | 
| 400 | 
            +
                    except Exception as e:
         | 
| 401 | 
            +
                        print(f"Error fetching suggestions: {e}")
         | 
| 402 | 
            +
             | 
| 403 |  | 
| 404 | 
             
                    return render_template(
         | 
| 405 | 
             
                        "cart.html",
         |