update cart/favorite
This commit is contained in:
@@ -6,7 +6,7 @@ library;
|
||||
/// Cart Item Entity
|
||||
///
|
||||
/// Contains item-level information:
|
||||
/// - Product reference
|
||||
/// - Product reference and basic info
|
||||
/// - Quantity
|
||||
/// - Pricing
|
||||
class CartItem {
|
||||
@@ -31,6 +31,15 @@ class CartItem {
|
||||
/// Timestamp when item was added
|
||||
final DateTime addedAt;
|
||||
|
||||
/// Product name from cart API
|
||||
final String? itemName;
|
||||
|
||||
/// Product image URL from cart API
|
||||
final String? image;
|
||||
|
||||
/// Conversion factor (m² to tiles) from cart API
|
||||
final double? conversionOfSm;
|
||||
|
||||
const CartItem({
|
||||
required this.cartItemId,
|
||||
required this.cartId,
|
||||
@@ -39,6 +48,9 @@ class CartItem {
|
||||
required this.unitPrice,
|
||||
required this.subtotal,
|
||||
required this.addedAt,
|
||||
this.itemName,
|
||||
this.image,
|
||||
this.conversionOfSm,
|
||||
});
|
||||
|
||||
/// Calculate subtotal (for verification)
|
||||
@@ -53,6 +65,9 @@ class CartItem {
|
||||
double? unitPrice,
|
||||
double? subtotal,
|
||||
DateTime? addedAt,
|
||||
String? itemName,
|
||||
String? image,
|
||||
double? conversionOfSm,
|
||||
}) {
|
||||
return CartItem(
|
||||
cartItemId: cartItemId ?? this.cartItemId,
|
||||
@@ -62,6 +77,9 @@ class CartItem {
|
||||
unitPrice: unitPrice ?? this.unitPrice,
|
||||
subtotal: subtotal ?? this.subtotal,
|
||||
addedAt: addedAt ?? this.addedAt,
|
||||
itemName: itemName ?? this.itemName,
|
||||
image: image ?? this.image,
|
||||
conversionOfSm: conversionOfSm ?? this.conversionOfSm,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ abstract class CartRepository {
|
||||
/// [itemIds] - Product ERPNext item codes
|
||||
/// [quantities] - Quantities for each item
|
||||
/// [prices] - Unit prices for each item
|
||||
/// [conversionFactors] - Conversion factors (m² to tiles) for each item
|
||||
///
|
||||
/// Returns true if successful.
|
||||
/// Throws exceptions on failure.
|
||||
@@ -32,6 +33,7 @@ abstract class CartRepository {
|
||||
required List<String> itemIds,
|
||||
required List<double> quantities,
|
||||
required List<double> prices,
|
||||
List<double?>? conversionFactors,
|
||||
});
|
||||
|
||||
/// Remove items from cart
|
||||
@@ -55,6 +57,7 @@ abstract class CartRepository {
|
||||
/// [itemId] - Product ERPNext item code
|
||||
/// [quantity] - New quantity
|
||||
/// [price] - Unit price
|
||||
/// [conversionFactor] - Conversion factor (m² to tiles)
|
||||
///
|
||||
/// Returns true if successful.
|
||||
/// Throws exceptions on failure.
|
||||
@@ -62,6 +65,7 @@ abstract class CartRepository {
|
||||
required String itemId,
|
||||
required double quantity,
|
||||
required double price,
|
||||
double? conversionFactor,
|
||||
});
|
||||
|
||||
/// Clear all items from cart
|
||||
|
||||
Reference in New Issue
Block a user