Skip to content

Commit

Permalink
fixd a buncha stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhav-pandya committed Jun 1, 2021
1 parent 775ca32 commit 3e19003
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 163 deletions.
2 changes: 1 addition & 1 deletion lib/models/Cart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ double getCheckoutPrice(List<CartProduct> yourCart) {
for (var i = 0; i < yourCart.length; i++) {
priceTotal += yourCart[i].numOfItem * yourCart[i].product.price;
}
return priceTotal;
return priceTotal.toInt().toDouble();
}

void placeOrder(List<CartProduct> yourCart) {
Expand Down
1 change: 1 addition & 0 deletions lib/models/Order.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Order{
'amount':price,
'date':date,
'userDetails': userDetails,
'timestamp': DateTime.now().millisecondsSinceEpoch,
'orderStatus': 'pending approval'
}).
then((value) =>{
Expand Down
9 changes: 8 additions & 1 deletion lib/models/Product.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ List<Product> supplementProductList = [];
List<Product> lifestyleProductList = [];
List<Product> tabletProductList = [];
List<Product> surgeryProductList = [];
List<Product> ayurvedaProductList = [];
List<Product> otherProductList = [];

Product getProductById(String id){
Expand Down Expand Up @@ -62,6 +63,8 @@ void getProductData() {
isPopular: true,
);
allProducts.add(product);
print("\n");
print(product.title+"\n");
if (doc["category"] == "lifestyle") {
lifestyleProductList.add(product);
} else if (doc["category"] == "tablet") {
Expand All @@ -70,11 +73,15 @@ void getProductData() {
supplementProductList.add(product);
} else if (doc["category"] == "surgery") {
surgeryProductList.add(product);
} else if (doc["category"] == "other") {
} else if (doc["category"] == "ayurveda") {
ayurvedaProductList.add(product);
}
else if (doc["category"] == "other") {
otherProductList.add(product);
}
})
});

}

List<Product> demoProducts = [
Expand Down
10 changes: 10 additions & 0 deletions lib/screens/cart/components/body.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:shop_app/components/default_button.dart';
import 'package:shop_app/constants.dart';
import 'package:shop_app/tutorial/tutorialAdditionals.dart';
Expand Down Expand Up @@ -129,6 +130,15 @@ class _BodyState extends State<Body> {
text: "Check Out",
press: () {
placeOrder(yourCart);
Fluttertoast.showToast(
msg: 'Order placed!',
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.TOP,
timeInSecForIos: 1,
backgroundColor: Colors.black,
textColor: Colors.white
);
Navigator.pop(context);
},
),
),
Expand Down
12 changes: 7 additions & 5 deletions lib/screens/product_list/components/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ class _BodyState extends State<Body> {
}

List<Product> getList(String category) {
if (category == "Lifestyle") {
if (category.toLowerCase() == "lifestyle") {
return lifestyleProductList;
} else if (category == "General") {
} else if (category.toLowerCase() == "general") {
return tabletProductList;
} else if (category == "Supplements") {
} else if (category.toLowerCase() == "supplements") {
return supplementProductList;
} else if (category == "Surgery") {
} else if (category.toLowerCase() == "surgery") {
return surgeryProductList;
} else if (category == "Other") {
} else if (category.toLowerCase() == "ayurveda") {
return ayurvedaProductList;
}else if (category.toLowerCase() == "other") {
return otherProductList;
}
}
Loading

0 comments on commit 3e19003

Please sign in to comment.