public void SetPayment(Payment p) { ShoppingItems.Payment = p; ShoppingItems.AcceptChanges(); AdjustTotals(true); }
public void Empty() { WebContext.Profile.Basket = null; _shoppingItems = new Basket(); ShoppingItems.AcceptChanges(); }
public void AdjustTotals(bool SaveSession) { decimal subTotal = 0; decimal total = 0; decimal discount = 0; decimal tax = 0; decimal shipping = 0; decimal giftVoucherValue = ShoppingItems.GiftVoucherValue; decimal weight = 0; decimal handling = 0; foreach (DataRow row in ShoppingItems.BasketItems.Rows) { row["Total"] = (decimal)row["UnitPrice"] * (decimal)row["Quantity"]; subTotal += (decimal)row["Total"]; discount += (decimal)row["Discount"]; tax += (decimal)row["Tax"]; weight += (decimal)row["Weight"] * (decimal)row["Quantity"]; } ShippingManager sm = new ShippingManager(); handling = sm.CalculateHandling(subTotal); total = subTotal - discount + tax + giftVoucherValue + handling + ShoppingItems.PaymentCost; if (false && lw.Members.Security.User.LoggedIn) { DataRow member = lw.Members.Security.User.LoggedInUser(null, true); if (member["Country"] != System.DBNull.Value) { shipping = sm.CalculateShipping(weight, member["Country"].ToString(), "All", subTotal); } total += shipping; } else { shipping = sm.CalculateShipping(weight, total); } total = subTotal - discount + tax + shipping - giftVoucherValue + handling + ShoppingItems.PaymentCost; if (total < 0) { total = 0; } ShoppingItems.Total = total; ShoppingItems.SubTotal = subTotal; ShoppingItems.Discount = discount; ShoppingItems.Tax = tax; ShoppingItems.Shipping = shipping; ShoppingItems.Handling = handling; if (SaveSession) { ShoppingItems.AcceptChanges(); } }