From b270a14c22d83e1611d47c12722eb8266857463b Mon Sep 17 00:00:00 2001 From: Rahul_Vijay Date: Sun, 27 Sep 2020 22:03:27 +0530 Subject: [PATCH] place order --- lib/screens/shoppingCart/loading.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/screens/shoppingCart/loading.dart b/lib/screens/shoppingCart/loading.dart index 0d1cfe0..8a2e9ac 100644 --- a/lib/screens/shoppingCart/loading.dart +++ b/lib/screens/shoppingCart/loading.dart @@ -40,7 +40,8 @@ class _OrderLoaderState extends State { StorageSharedPrefs p = new StorageSharedPrefs(); String userId = await p.getId(); String token = await p.getToken(); - String url = APIService.ordersAPI + "/new/$userId"; + String hubid = await p.gethub(); + String url = APIService.ordersAPI + "new/$userId/$hubid"; Map requestHeaders = {'x-auth-token': token}; // make the body OrderModel newOrder = new OrderModel( @@ -63,7 +64,8 @@ class _OrderLoaderState extends State { itemId: newCart.items[i].id, name: newCart.items[i].name, totalPrice: "${newCart.items[i].totalPrice}", - totalQuantity: "$q ${newCart.items[i].quantity.quantityMetric}", + totalQuantity: + "$q ${newCart.items[i].details[0].quantity.quantityMetric}", ); itemList.add(it); } @@ -81,14 +83,16 @@ class _OrderLoaderState extends State { Navigator.pushReplacementNamed(context, "/ordersNew"); } else if (response.statusCode == 404) { Fluttertoast.showToast( - msg: "404 error", + msg: "Failed to place order. Please contact Support..", toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM); + Navigator.pushReplacementNamed(context, "/main"); } else if (response.statusCode == 500) { Fluttertoast.showToast( - msg: "500 error", + msg: "Failed to place order. Please contact Support.", toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM); + Navigator.pushReplacementNamed(context, "/main"); } else throw Exception("Server error!"); }