Skip to content

Food Ordering Widgets APIs

Show/Hide widgets APIs (intents)

The shopping cart is controlled by the following intents.

Display and update the shopping cart

Intent Action → "com.telenav.commerce.widgets.UPDATE_SHOPPING_CART_WIDGET"


Display/Update shopping cart intent

1
2
3
4
5
6
7
8
9
Intent(
    "com.telenav.commerce.widgets.UPDATE_SHOPPING_CART_WIDGET",
    Uri.parse("telenav://commerce.widgets")
)

intent.putExtra(
    "data_key",
    Gson().toJson(foodShoppingCartModel)
)

The extra sent in the intent is a FoodShoppingCartModel object converted to json file.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data class FoodShoppingCartModel(
    @SerializedName("conversation_id")
    val conversationId: String? = null,
    val brand: Brand? = null,
    @SerializedName("shopping_cart")
    val foodShoppingCart: FoodShoppingCart? = null,
    @SerializedName("store")
    val foodStore: FoodStore? = null,
    @SerializedName("screen_id")
    val screenId: String? = null
) : Serializable

Here is an example code of FoodShoppingCartModel to Json.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
    "conversation_id":"12345",
    "brand":{
    "images":[

    ],
    "key":"7",
    "name":"Mod Pizza"
},
    "shopping_cart":{
    "delivery_method":"CARRY_OUT",
    "payment_type":"PAY_AT_MERCHANT",
    "products":[

    ],
    "total_price":null
},
    "store":{
    "address":{
    "city":"Tamuning",
    "country":"US",
    "formatted_address":"1227 Pale San Vitores Rd, Tamuning GU 96913, US",
    "geo_coordinates":{
    "lat":37.78304672241211,
    "lon":-122.4242172241211
},
    "nav_coordinates":{
    "lat":37.78304672241211,
    "lon":-122.4242172241211
},
    "state":"GU",
    "street":{
    "formatted_name":"1227 Pale San Vitores Rd"
}
},
    "amenities":[

    ],
    "distance":0,
    "restaurant_eta":180,
    "is_novo_supported":false,
    "is_open":false,
    "name":"MOD Pizza Call Center **Mock**",
    "phone_numbers":[
    "12122600895"
    ],
    "price_info":{

},
    "search_type":"NEARBY",
    "time_until_closing":0
}
}

Show food order complete widget

Intent Action → "com.telenav.commerce.widgets.SHOW_ORDER_COMPLETE_WIDGET"


Show Order Complete screen intent

1
2
3
4
5
6
7
8
9
Intent(
    "com.telenav.commerce.widgets.SHOW_ORDER_COMPLETE_WIDGET",
    Uri.parse("telenav://commerce.widgets")
)

intent.putExtra(
    "data_key",
    Gson().toJson(foodShoppingCartModel)
)  

Close the shopping cart

Intent Action → "com.telenav.commerce.widgets.CLOSE_FOOD_FLOW_WIDGET"

Close shopping cart intent
1
2
3
4
Intent(
    "com.telenav.commerce.widgets.CLOSE_FOOD_FLOW_WIDGET",
    Uri.parse("telenav://commerce.widgets")
)

Opening the shopping cart

The shopping cart can be opened in two ways.

1. Through an intent

Example code on how to use the UPDATE_SHOPPING_CART_WIDGET intent.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
val intent = Intent(
    "com.telenav.commerce.widgets.UPDATE_SHOPPING_CART_WIDGET",
    Uri.parse("telenav://commerce.widgets")
)
intent.putExtra(
    "data_key",
    Gson().toJson(foodShoppingCartModel)
)

requireActivity().sendBroadcast(intent)

Info

Please find the foodShoppingCartModel object defined above.

2. Through Android FragmentManager

The ShoppingCartFoodFragment can be also opened as a regular fragment in Android and pass the FoodShoppingCartModel object in a Bundle.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
val bundle = Bundle().apply {
    putSerializable("bundle_key", foodShoppingCartModel)
}

this.supportFragmentManager.beginTransaction().add(
    R.id.widgets_fragment,
    ShoppingCartFoodFragment::class.java,
    bundle,
    ShoppingCartFoodFragment::class.java.name
).commit()

Info

Please find the foodShoppingCartModel object defined above.

Closing the shopping cart

The Shopping cart can be closed in two ways.

1. Through an intent

Example code on how to use the CLOSE_FOOD_FLOW_WIDGET intent.

1
2
3
4
5
6
val intent = Intent(
    "com.telenav.commerce.widgets.CLOSE_FOOD_FLOW_WIDGET",
    Uri.parse("telenav://commerce.widgets")
)

requireActivity().sendBroadcast(intent)

2. Through Android FragmentManager

1
fragmentManager?.popBackStack()