public static void RemoveCartItemsFromOffers(CrossSellViewModel vm, Jungo.Models.ShopperApi.Cart.Cart cart) { // remove what is already in the cart from the cross-sell offers if (vm == null || vm.Offers == null || cart == null || cart.LineItems == null || cart.LineItems.LineItem == null || cart.LineItems.LineItem.Length <= 0) return; foreach (var offer in vm.Offers.Where(offer => offer.ProductOffersOfferViewModels != null && offer.ProductOffersOfferViewModels.Length > 0)) { offer.ProductOffersOfferViewModels = offer.ProductOffersOfferViewModels.Where( povm => cart.LineItems.LineItem.All(li => li.Product.Id != povm.Product.Id)) .ToArray(); } }
// public for testing only public ShoppingCartViewModel MakeShoppingCartViewModel(Jungo.Models.ShopperApi.Cart.Cart cart) { return new ShoppingCartViewModel { Count = cart.TotalItemsInCart, SubTotal = cart.Pricing.Subtotal != null ? cart.Pricing.Subtotal.Value : 0.0M, Discount = cart.Pricing.Discount != null ? cart.Pricing.Discount.Value : 0.0M, ShippingAndHandling = cart.Pricing.ShippingAndHandling != null ? cart.Pricing.ShippingAndHandling.Value : 0.0M, Tax = cart.Pricing.Tax != null ? cart.Pricing.Tax.Value : 0.0M, Total = cart.Pricing.OrderTotal != null ? cart.Pricing.OrderTotal.Value : 0.0M, Cart = cart, IsShoppingCartLocked = false, }; }
public MiniShoppingCart(Jungo.Models.ShopperApi.Cart.Cart cart) { Count = cart.TotalItemsInCart; SubTotal = cart.Pricing.Subtotal; Discount = cart.Pricing.Discount; ShippingAndHandling = cart.Pricing.ShippingAndHandling; Tax = cart.Pricing.Tax; Total = cart.Pricing.OrderTotal; LineItems = cart.LineItems .LineItem .Select(lineItem => new MiniShoppingCartLineItem { LineItemId = lineItem.Id.ToString(CultureInfo.InvariantCulture), Description = lineItem.Product.ShortDescription, Image = lineItem.Product.ProductImage, Quantity = lineItem.Quantity, UnitPrice = lineItem.Pricing.ListPrice, SubTotal = lineItem.Pricing.SalePriceWithQuantity }); }
/// <summary> /// Create a product detail link for a product in the shopping cart /// </summary> /// <param name="html"></param> /// <param name="product">A product in the shopping cart</param> /// <returns></returns> public static string BaseProductDetailLink(this HtmlHelper html, Jungo.Models.ShopperApi.Common.Product product) { return html.AssureHttpUrl(LinkGenerator.GenerateProductLink(product.Id)); }