getTotalPrice method

double getTotalPrice()

Gets the total price of all items in the shopping cart.

Implementation

double getTotalPrice() {
  var box = Hive.box<PersistentShoppingCartItem>('cartBox');

  double totalAmount = 0;

  // Iterate through each item in the cart and calculate the total price
  for (var i = 0; i < box.length; i++) {
    PersistentShoppingCartItem item = box.getAt(i)!;
    totalAmount += item.totalPrice;
  }

  return totalAmount;
}