diff --git a/lib/components/checkout_form.dart b/lib/components/checkout_form.dart index 3d90865..b42e752 100644 --- a/lib/components/checkout_form.dart +++ b/lib/components/checkout_form.dart @@ -61,6 +61,8 @@ class _CheckoutFormState extends State { "data": cartData, }; + await clearCart(); + var statusCode = await loadCheckout(data); return statusCode; } diff --git a/lib/data/cart.dart b/lib/data/cart.dart index c51619e..960e74d 100644 --- a/lib/data/cart.dart +++ b/lib/data/cart.dart @@ -37,6 +37,12 @@ Future removeFromCart(productId, bool batch) async { box.put('cart', jsonEncode(cart).toString()); } +Future clearCart() async { + final box = Hive.box(); + + box.put('cart', '[]'); +} + Future viewCart() async { final box = Hive.box();