@@ -22,7 +22,6 @@ class CartDataSourceImpl extends CartDataSource {
2222 if (response.data is List <dynamic >) {
2323 return CartResponse .empty ();
2424 }
25- response.data;
2625 var data = CartResponse .fromJson (response.data);
2726 for (var cartItem in data.items) _db.addToCart (cartItem.id);
2827 return data;
@@ -32,12 +31,32 @@ class CartDataSourceImpl extends CartDataSource {
3231 Future <Response > addItem (int id, int count) => _sendUserRequest ()
3332 .then ((dio) => dio.post ('cart/add-item' , data: {
3433 'id' : id,
35- 'quantity' : count
34+ 'quantity' : count,
3635 })).then ((response) {
3736 if (response.statusCode == 200 ) _db.addToCart (id);
3837 return response;
3938 });
4039
40+ @override
41+ Future <Response > addVariableItem (
42+ int id,
43+ int count,
44+ Map <String , dynamic > variation,
45+ ) =>
46+ _sendUserRequest ().then (
47+ (dio) => dio.post (
48+ 'cart/add-item' ,
49+ data: {
50+ 'id' : id,
51+ 'quantity' : count,
52+ 'variation' : variation,
53+ },
54+ ),
55+ ).then ((response) {
56+ if (response.statusCode == 200 ) _db.addToCart (id);
57+ return response;
58+ });
59+
4160 @override
4261 Future <Response > updateQuantity (String itemKey, int count) => _sendUserRequest ()
4362 .then ((dio) => dio.post ('cart/item/$itemKey ' , data: {
@@ -72,6 +91,8 @@ abstract class CartDataSource {
7291
7392 Future <Response > addItem (int id, int count);
7493
94+ Future <Response > addVariableItem (int id, int count, Map <String , dynamic > variation);
95+
7596 Future <Response > updateQuantity (String itemKey, int count);
7697
7798 Future <CartResponse > deleteItem (String itemKey, int originalId);
0 commit comments