---
# System prepended metadata

title: Order Process

---

# Order Process




```mermaid
graph TD
    Home[[Homeview]]-->
    action1[Click products]-->
    Query1>"GetRestaurants with filters #9721;1"]-->
    Locations[["Show same list as nearest <br> cafes or locations with only cafes"]]-->
    action2[Select location for pickup]-->
    Query2>"GetProductMenu with <br>selected locationID #9721;2"]-->
    Products[["Show products #9699;1"]]-->buttonAdd2Basket["addToBasket click"]
    Products-->
    action3["Click product"]-->
    Query3>"GetProductById #9721;3"]-->
    Product[["Show single product view"]]-->
    buttonAdd2Basket-->
    Query31>"GetProductById #9721;3"]-->
    cont[["Product configuration <br> continues after queries and views"]]
```

## GraphQL queries

#### &#9721; 1 -- GetRestaurants

* Order closest to user current location (same as show nearest)
* Show only restaurant
* Hide filters
* Save selected location ID

Query:

```
query GetRestaurants($lang: Locale!) {
  locations(where: {locationType: restaurant}, first: 100, locales: [$lang, en]) {
    id
    city
    coordinates
    country
    extraData
    localizations(includeCurrent: true) {
      country
    }
    image {
      url
    }
    locationType
    stage
    name
    openingHours
    postalCode
    street
    telephoneNumber
    exceptions
  }
}
```
---

#### &#9721; 2 -- GetProductMenu

* Will hide products that are not available in selected location
```
where: { productHidden_none: {id: $locationId}...
```     
* Contains exceptions for as key:value pairs if product salesPrice is different from default (locationId:newPrice)
```
productPriceData {
      ...
      priceSalesExceptions
    }
```     

query:

```
query GetProductMenu($lang: Locale!, $SelectedLocationId: $locationId) {
  products(
    where: { productHidden_none: {id: $locationId}, active: true, isModifier: false }
    orderBy: order_ASC
    locales: [$lang, en]
    first: 100
  ) {
    productId
    id
    productName
    productPriceData {
      priceSales
      vatRate
      priceSalesExceptions
    }
    productImage {
      url
    }
    productCategory
    productAllergen {
      allergensContained
      allergensPossible
      dietaryCategories
    }
  }
}
```

#### &#9721; 3 -- GetProductById

 

query:

```
query GetProductById($productId: Int, $lang: Locale!) {
  product(
    where: { productId: $productId, active: true }
    locales: [$lang, en]
  ) {
    productId
    id
    productName
    productPosData {
      posUuid
    }
    productPriceData {
      priceSales
      vatRate
    }
    productImage {
      url
    }
    productCategory
    productSubCategory
    productDescriptionShort
    productDescriptionLong
    productInfo
    productAllergen {
      allergensContained
      allergensPossible
      dietaryCategories
    }
    productNutrition {
      carbs
      carbsSugars
      energyKilocalories
      energyKilojoules
      fat
      fatSaturated
      lactose
      productWeight
      protein
      salt
    }
    productNutrition100 {
      carbs
      carbsSugars
      energyKilocalories
      energyKilojoules
      fat
      fatSaturated
      lactose
      productWeight
      protein
      salt
    }
    defaultModifiers {
      isModifierGroup
      productName
      allowMultipleSelection
      defaultModifiers {
        productName
        productPosData {
          id
        }
      }
    }
    optionalModifiers {
      isModifierGroup
      productName
      allowMultipleSelection
      defaultModifiers {
        productName
        productPosData {
          id
        }
        productPriceData {
          priceSales
          vatRate
        }
      }
    }
    productVariations {
      productId
      id
      productName
      productImage {
        url
      }
      productPosData {
        posUuid
      }
      productPriceData {
        priceSales
        vatRate
        priceSalesExceptions
      }
    }
    additionalProducts{
      productId
      id
      productName
      productImage {
        url
      }
      productPosData {
        posUuid
      }
      productPriceData {
        priceSales
        vatRate
        priceSalesExceptions
      }
    }
  }
}
```

---

## Views

#### &#9699;1 Menu/Products

1. Some products might not be available in selected location

```
where: { productHidden_none: {id: $locationId}, acti...
```
will hande this problem.

2. Product prices may vary in different location 

```
"priceSalesExceptions": {
            "clftjm3t49k5b0bulvqxpqxel": "3.9",
            "clftjh9se9nxz0bw8lfrracxq": "3.7",
          }
```
Need to check if object contains currentLocationId use exception price

---

## Add to basket product customization



```mermaid
graph TD


    Prod[[Customize product]]-->
    Query3>"GetProductById #9721;3"]-->
    check11{"posUuid"} 

    ProdType1["Single product"]
    ProdType2["Product is combination"]

    check11-->|notNull| ProdType1
    -->cNumOfProd[\"Show: select number of products"\]
    check11-->|null| ProdType2
    
    subgraph defaultloop
        checkDefault["Loop through defaultModifiers"]-->
        check21{"isModifierGroup"}
        check21-->|true| defaultAllowMulti{"allowMultipleSelection == false"}
        check21-->|false| defaultShowBoolean[\"Show: select true/false"\]
        
        defaultAllowMulti-->|Allow multiple select| showDfltLift[\"Show: product group content list"\]
        defaultAllowMulti-->|Allow single select| showDfltLift
        
        defaultSavePOSUuids["Save posUuid(s)"]
        
        
        defaultShowBoolean-->defaultSavePOSUuids
        showDfltLift-->defaultSavePOSUuids
            
        defaultSavePOSUuids-->defaultAffectTotalSum["Selections do not affect end sum"]
    
    end
    
    subgraph optionalloop
        checkOptional["Loop through optionaModifiers"]
        checkOptional-->check31{"isModifierGroup"}
        check31-->|true| optionalAllowMulti{"allowMultipleSelection"}
        check31-->|false| optionalShowBoolean[\"Show select true/false"\]
        
        optionalAllowMulti-->|Allow multiple select| showOptLift[\"Show: product group content list"\]
        optionalAllowMulti-->|Allow single select| showOptLift
        
        optSavePOSUuids["Save posUuid(s)"]
        
        optionalShowBoolean-->optSavePOSUuids
        showOptLift-->optSavePOSUuids
        
        
        optSavePOSUuids-->optAffectTotalSum["Save prices from optional selections for end sum"]    
    end
    
    subgraph productVariations
        checkVariations["Loop through variations"]-->showVariations[\"Show product variations"\]
    end
    
    subgraph additionalProducts
        checkAdditional["Loop through additions"]-->showAdditions[\"Show possible additions"\]
    end
    
    
    
    ProdType2-->checkDefault
    defaultAffectTotalSum-->checkOptional
    cNumOfProd-->checkVariations
    
    showVariations-->checkAdditional
    optAffectTotalSum-->checkAdditional
    
    showAdditions-->ConfirmAdd[["Confirm adding product to basket"]]
    
```


