private IEnumerable <net.taxcloud.api.CartItem> CreateCartShippingLineItem(Customer customer, IEnumerable <CartItem> cartItems, IEnumerable <OrderOption> orderOptions) { net.taxcloud.api.CartItem lineItem = new net.taxcloud.api.CartItem { Index = 0, ItemID = ShippingItemSku, Price = Localization.ParseNativeDouble(Prices.ShippingTotal(true, true, new CartItemCollection(cartItems), customer, orderOptions).ToString()), Qty = 1.0f, TIC = APiShippingTaxClassCode, }; yield return(lineItem); }
private IEnumerable <net.taxcloud.api.CartItem> CreateOrderShippingLineItem(Order order, int destAddressId) { var shippingAmount = new OrderShipmentCollection(order.OrderNumber) .Where(os => os.AddressID == destAddressId) .Select(os => os.ShippingTotal) .FirstOrDefault(); net.taxcloud.api.CartItem lineItem = new net.taxcloud.api.CartItem { Index = 0, ItemID = ShippingItemSku, Price = (double)shippingAmount, Qty = 1.0f, TIC = APiShippingTaxClassCode, }; yield return(lineItem); }
private IEnumerable <net.taxcloud.api.CartItem> ConvertCartItems(IEnumerable <CartItem> cartItems, Customer customer, List <CouponObject> CouponList, List <QDObject> QuantityDiscountList) { IList <net.taxcloud.api.CartItem> refCartItems = new List <net.taxcloud.api.CartItem>(); foreach (CartItem i in cartItems) { decimal extendedPrice = Decimal.Zero; if (i.ThisShoppingCart == null) { // Order line items using (var promotionsDataContext = new AspDotNetStorefront.Promotions.Data.EntityContextDataContext()) { // Sum the discount for every PromotionLineItem that applies to the current cart item. // A gift product's line item price is already discounted, so don't include the discount when IsAGift is true. var lineItemDiscountAmount = promotionsDataContext.PromotionLineItems .Where(pli => !pli.isAGift) .Where(pli => pli.shoppingCartRecordId == i.ShoppingCartRecordID) .Sum(pli => (decimal?)pli.discountAmount); extendedPrice = i.Price + (lineItemDiscountAmount ?? 0); } } else { // Shopping cart items extendedPrice = Prices.LineItemPrice(i, CouponList, QuantityDiscountList, customer); } net.taxcloud.api.CartItem refCartItem = new net.taxcloud.api.CartItem() { Index = i.ShoppingCartRecordID, ItemID = i.SKU, TIC = Localization.ParseNativeInt(new TaxClass(i.TaxClassID).TaxCode), Price = (double)extendedPrice / i.Quantity, Qty = (float)i.Quantity, }; refCartItems.Add(refCartItem); } return(refCartItems); }