private void InitLineShippingOptions(CheckoutViewModel model) { if (!model.HasLines) { return; } var prefsResponse = ShippingManager.GetShippingPreferences(model.Cart); if (!prefsResponse.ServiceProviderResult.Success || prefsResponse.Result == null) { return; } var lineShippingOptions = prefsResponse.ServiceProviderResult.LineShippingPreferences.ToList(); foreach (CommerceCartLineWithImages line in model.Cart.Lines) { var option = lineShippingOptions?.FirstOrDefault(lso => lso.LineId == line.ExternalCartLineId)?.ShippingOptions?.FirstOrDefault(); model.LineShippingOptions[line.ExternalCartLineId] = option; } SetShippingMethods(model); }
private Money CalculateShippingCostSubTotal(IEnumerable <Shipment> shipments, CartHelper cartHelper) { var retVal = new Money(0, cartHelper.Cart.BillingCurrency); foreach (Shipment shipment in shipments) { if (cartHelper.FindAddressByName(shipment.ShippingAddressId) == null) { continue; } var methods = ShippingManager.GetShippingMethods(CurrentPage.LanguageID); var shippingMethod = methods.ShippingMethod.FirstOrDefault(c => c.ShippingMethodId.Equals(shipment.ShippingMethodId)); if (shippingMethod == null) { continue; } var shipmentRateMoney = SampleStoreHelper.GetShippingCost(shippingMethod, shipment, cartHelper.Cart.BillingCurrency); retVal += shipmentRateMoney; } return(retVal); }
public virtual ShippingDetailsResponse GetShippingDetails(string orderId, string contactId, string marketId, string cartName, ShippingRequest shippingRequest) { var cart = _vippsService.GetCartByContactId(contactId, marketId, cartName); var shippingMethods = ShippingManager.GetShippingMethodsByMarket(cart.MarketId.Value, false).ShippingMethod.ToList().OrderBy(x => x.Ordering); var shippingDetails = new List <ShippingDetails>(); var counter = 1; foreach (var shippingMethod in shippingMethods) { lock (cart) { var shipment = cart.GetFirstShipment(); shipment.ShippingAddress = AddressHelper.ShippingRequestToOrderAddress(shippingRequest, cart); shipment.ShippingMethodId = shippingMethod.ShippingMethodId; cart.ApplyDiscounts(); shippingDetails.Add(new ShippingDetails { ShippingMethodId = shippingMethod.ShippingMethodId.ToString(), ShippingCost = Convert.ToDouble(cart.GetShippingTotal().Amount), ShippingMethod = shippingMethod.DisplayName, Priority = shippingMethod.IsDefault ? 0 : counter++ }); } } return(new ShippingDetailsResponse { OrderId = orderId, ShippingDetails = shippingDetails }); }
private void InitLineShippingOptions(CheckoutViewModel model) { if (!model.HasLines) { return; } var prefsResponse = ShippingManager.GetShippingPreferences(model.Cart); if (!prefsResponse.ServiceProviderResult.Success || prefsResponse.Result == null) { return; } foreach (CommerceCartLineWithImages line in model.Cart.Lines) { //var option = model.ShippingOptions?.FirstOrDefault(so => // so.Key == GetShippingOptionID(model)); model.LineShippingOptions[line.ExternalCartLineId] = new ShippingOption() { Name = "Ship items", Description = "Ship items", ShippingOptionType = ShippingOptionType.ShipToAddress }; } SetShippingMethods(model); }
private string CheckApplicableShippings(string code) { /* load the Shipping-Method-Parameters and inspect what method will be used... * for now, just output text to the page, could also use it for loading "the right" method-guid * for the second shipment added */ string str = String.Empty; // get the rows, we don't care about the market-part now ShippingMethodDto dto = ShippingManager.GetShippingMethodsByMarket (MarketId.Default.Value, false); foreach (ShippingMethodDto.ShippingMethodRow shippingMethod in dto.ShippingMethod) { // This is the interesting part, could be complemented with dbo.ShippingOptionParameter // get the param-rows, could show the dbo.ShippingMethodParameter table in VS ShippingMethodDto.ShippingMethodParameterRow[] paramRows = shippingMethod.GetShippingMethodParameterRows(); if (paramRows.Count() != 0) { // right now we're just outputting text to the cart // ... should more likely get the guid instead // could be here we can match lineItem with the shipping method or gateway foreach (var shippingMethodParameter in paramRows) { str += shippingMethod.Name + " : " + shippingMethodParameter.Parameter + " or "; var v = shippingMethodParameter.Value; // ...not in use... yet... } } } return(str); }
/// <summary> /// Checks the warehouse assigned to an order line item to determine if it is a valid shipment fulfillment location /// (i.e. will ship items to a customer address) /// </summary> /// <param name="warehouse">The intended source warehouse.</param> /// <param name="lineItem">The order line item.</param> /// <param name="checkInventory">Set to false to override the check against current stock.</param> /// <returns> /// true if the warehouse can ship the item and a pickup method is not already chosen; otherwise false /// (i.e. the warehouse cannot ship the item, or the line item has an in-store pickup method selected). /// </returns> private bool IsValidFulfillment(IWarehouse warehouse, LineItem lineItem, CheckInventoryMode checkInventory) { if (warehouse == null || lineItem == null) { throw new ArgumentNullException(); } var shippingMethod = ShippingManager.GetShippingMethod(lineItem.ShippingMethodId).ShippingMethod.FirstOrDefault(); if (shippingMethod != null && ShippingManager.IsHandoffShippingMethod(shippingMethod.Name)) { return(false); } var lineApplicationId = lineItem.Parent.Parent.ApplicationId; if ((warehouse.ApplicationId != lineApplicationId) || !warehouse.IsActive || !warehouse.IsFulfillmentCenter) { return(false); } if (checkInventory == CheckInventoryMode.Ignore) { return(true); } var catalogKey = new Mediachase.Commerce.Catalog.CatalogKey(lineItem.Parent.Parent.ApplicationId, lineItem.CatalogEntryId); var inventory = InventoryService.Service.Get(catalogKey, warehouse); return(IsEnoughQuantity(inventory, lineItem)); }
private Guid GetShipMethodByParam(string paramCodeValue) { var paramRow = ShippingManager.GetShippingMethodsByMarket(MarketId.Default.Value, false). ShippingMethodParameter.Where(p => p.Value == paramCodeValue).FirstOrDefault(); return(paramRow.ShippingMethodId); }
public EstimateQuery BuildEstimateQuery(IShipment shipment, Guid shippingMethodId) { var shipmentLineItems = shipment.LineItems; var shippingMethod = ShippingManager.GetShippingMethod(shippingMethodId); return(BuildQuery(shipment, shippingMethod, shipmentLineItems)); }
// POST public async System.Threading.Tasks.Task <IHttpActionResult> PostAsync(Shipping shipping) { var mngEmail = new EmailManager(); var email = new Email { Mail = shipping.Email, Name_1 = shipping.Name, Last_Name_1 = " " }; await mngEmail.Send(email); try { var mng = new ShippingManager(); mng.Create(shipping); apiResp = new ApiResponse(); apiResp.Message = "Se ha registrado correctamente."; return(Ok(apiResp)); } catch (BussinessException bex) { return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message))); } }
public virtual ShippingMethodInfoModel GetInstorePickupModel() { var methodDto = ShippingManager.GetShippingMethods(null); if (methodDto == null || !methodDto.ShippingMethod.Any()) { return(null); } var method = methodDto.ShippingMethod.FirstOrDefault(x => x.Name.Equals(ShippingManager.PickupShippingMethodName)); if (method == null) { method = methodDto.ShippingMethod.FirstOrDefault(); } return(new ShippingMethodInfoModel { MethodId = method.ShippingMethodId, Currency = method.Currency, LanguageId = method.LanguageId, Ordering = method.Ordering, ClassName = methodDto.ShippingOption.FindByShippingOptionId(method.ShippingOptionId).ClassName }); }
public JsonResult GetShippingMethods(GetShippingMethodsInputModel inputModel) { try { Assert.ArgumentNotNull(inputModel, nameof(inputModel)); var validationResult = this.CreateJsonResult(); if (validationResult.HasErrors) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var response = ShippingManager.GetShippingMethods(CommerceUserContext.Current.UserId, inputModel); var result = new ShippingMethodsApiModel(response.ServiceProviderResult); if (response.ServiceProviderResult.Success) { result.Initialize(response.ServiceProviderResult.ShippingMethods, response.ServiceProviderResult.ShippingMethodsPerItem); } return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new ErrorApiModel("GetShippingMethods", e), JsonRequestBehavior.AllowGet)); } }
private IEnumerable <ShippingOption> GetShippingOptions(ICart cart, Currency currency, CultureInfo preferredCulture) { var methods = ShippingManager.GetShippingMethodsByMarket(cart.Market.MarketId.Value, false); var currentLanguage = preferredCulture.TwoLetterISOLanguageName; var shippingOptions = methods.ShippingMethod .Where(shippingMethodRow => currentLanguage.Equals(shippingMethodRow.LanguageId, StringComparison.OrdinalIgnoreCase) && string.Equals(currency, shippingMethodRow.Currency, StringComparison.OrdinalIgnoreCase)) .Select(method => method.ToShippingOption()) .ToList(); var shipment = cart.GetFirstShipment(); if (shipment == null) { return(shippingOptions); } // Try to preselect a shipping option var selectedShipment = shippingOptions.FirstOrDefault(x => x.Id.Equals(shipment.ShippingMethodId.ToString())); if (selectedShipment != null) { selectedShipment.PreSelected = true; } return(shippingOptions); }
private int GetPackageId(string package) { ShippingMethodDto shippingDto = ShippingManager.GetShippingPackages(); if (shippingDto.Package != null) { DataRow[] drws = null; int packageId = 0; if (Int32.TryParse(package, out packageId)) { drws = shippingDto.Package.Select(String.Format("PackageId = '{0}'", packageId)); if (drws.Length > 0) { return(packageId); } } else { drws = shippingDto.Package.Select(String.Format("Name LIKE '{0}'", package.Replace("'", "''"))); if (drws.Length > 0) { return(((ShippingMethodDto.PackageRow)drws[0]).PackageId); } } } return(0); }
/// <summary> /// Initializes a new instance of the <see cref="CheckoutController" /> class. /// </summary> /// <param name="cartManager">The cart manager.</param> /// <param name="orderManager">The order manager.</param> /// <param name="loyaltyProgramManager">The loyalty program manager.</param> /// <param name="accountManager">The account manager.</param> /// <param name="paymentManager">The payment manager.</param> /// <param name="shippingManager">The shipping manager.</param> /// <param name="storeManager">The store manager.</param> /// <param name="contactFactory">The contact factory.</param> public CheckoutController( [NotNull] CartManager cartManager, [NotNull] OrderManager orderManager, [NotNull] LoyaltyProgramManager loyaltyProgramManager, [NotNull] AccountManager accountManager, [NotNull] PaymentManager paymentManager, [NotNull] ShippingManager shippingManager, [NotNull] StoreManager storeManager, [NotNull] ContactFactory contactFactory) : base(accountManager, contactFactory) { Assert.ArgumentNotNull(cartManager, "cartManager"); Assert.ArgumentNotNull(orderManager, "orderManager"); Assert.ArgumentNotNull(loyaltyProgramManager, "loyaltyProgramManager"); Assert.ArgumentNotNull(paymentManager, "paymentManager"); Assert.ArgumentNotNull(shippingManager, "shippingManager"); Assert.ArgumentNotNull(storeManager, "storeManager"); this.CartManager = cartManager; this.OrderManager = orderManager; this.LoyaltyProgramManager = loyaltyProgramManager; this.PaymentManager = paymentManager; this.ShippingManager = shippingManager; this.StoreManager = storeManager; }
/// <summary> /// Creates the empty dto. /// </summary> /// <param name="sm">The sm.</param> /// <param name="persistInSession">if set to <c>true</c> [persist in session].</param> private void CreateEmptyDto(ref ShippingMethodDto sm, bool persistInSession) { if (sm == null || sm.ShippingMethod.Count == 0) { // fill dto with all available shipping options. They will be needed for contraints to work properly when a new shipping method is created. sm = ShippingManager.GetShippingMethods(LanguageCode, true); // remove shipping methods, because we need an empty dto. if (sm != null) { if (sm.ShippingMethod.Count > 0) { while (sm.ShippingMethod.Rows.Count > 0) { sm.ShippingMethod.Rows.RemoveAt(0); } } } if (persistInSession) { Session[GetShippingMethodSessionKey()] = sm; } } }
private void AdjustFirstShipmentInOrder(ICart cart, IOrderAddress orderAddress, Guid selectedShip) { // Need to set the guid (name is good to have too) of some "real shipmentment in the DB" // RoCe - this step is not needed, actually - code and lab-steps can be updated // We'll do it to show how it works var shippingMethod = ShippingManager.GetShippingMethod(selectedShip).ShippingMethod.First(); IShipment theShip = cart.GetFirstShipment(); // ...as we get one "for free" // Need the choice of shipment from DropDowns theShip.ShippingMethodId = shippingMethod.ShippingMethodId; //theShip.ShippingMethodName = "TucTuc"; theShip.ShippingAddress = orderAddress; #region Hard coded and cheating just to show // RoCe: - fix the MarketService var mSrv = ServiceLocator.Current.GetInstance <IMarketService>(); var defaultMarket = mSrv.GetMarket(MarketId.Default); // cheating some Money cost00 = theShip.GetShippingCost(_currentMarket.GetCurrentMarket(), new Currency("USD")); Money cost000 = theShip.GetShippingCost(_currentMarket.GetCurrentMarket(), cart.Currency); #endregion Money cost0 = theShip.GetShippingCost( _currentMarket.GetCurrentMarket() , _currentMarket.GetCurrentMarket().DefaultCurrency); // to make it easy // done by the "default calculator" Money cost1 = theShip.GetShippingItemsTotal(_currentMarket.GetCurrentMarket().DefaultCurrency); theShip.ShipmentTrackingNumber = "ABC123"; }
private void CreateExpression(int promotionId, string name) { var xml = String.Empty; if (name.Equals("25 % off Mens Shoes")) { using (var sr = new StreamReader(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\Promotions\25_Percent_off_Mens_Shoes.xml"))) { xml = sr.ReadToEnd(); } } else if (name.Equals("$50 off Order over $500")) { using (var sr = new StreamReader(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\Promotions\50_off_Order_over_500.xml"))) { xml = sr.ReadToEnd(); } } else if (name.Equals("$10 off shipping from Women's Shoes")) { using (var sr = new StreamReader(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\Promotions\10_off_shipping_from_Womens_Shoes.xml"))) { xml = sr.ReadToEnd(); } xml = xml.Replace("fc7c2d53-7c1c-4298-8189-f8b1f8e85439", ShippingManager.GetShippingMethods("en").ShippingMethod.FirstOrDefault(x => x.LanguageId.Equals("en") && x.Name.Contains("Express") && x.Currency.Equals("USD")).ShippingMethodId.ToString().ToLower()); } xml = xml.Replace("'", "''"); var sql = String.Format("INSERT INTO [dbo].[Expression] ([ApplicationId], [Name], [Description], [Category], [ExpressionXml], [Created], [Modified], [ModifiedBy]) VALUES (N'{0}', N'{1}', N'{1}', N'Promotion', '{2}', N'20150430 09:55:05.570', NULL, N'admin')", AppContext.Current.ApplicationId, name.Replace("'", "''"), xml); ExecuteSql(sql); sql = String.Format("INSERT INTO [dbo].[PromotionCondition] ([PromotionId], [ExpressionId], [CatalogName], [CatalogNodeId], [CatalogEntryId]) VALUES ({0}, {0}, NULL, NULL, NULL)", promotionId); ExecuteSql(sql); }
private IEnumerable <ShippingMethodAndRate> GetShippingMethodsWithRates(Cart cart, OrderAddress address) { ShippingMethodDto shippingMethods = ShippingManager.GetShippingMethods(CurrentPage.LanguageID, false); List <ShippingMethodAndRate> shippingMethodsList = new List <ShippingMethodAndRate>(); string outputMessage = string.Empty; string shippingMethodAndPrice = string.Empty; //get the one shipment in the order Shipment ship = null; if (cart.OrderForms[0].Shipments != null && cart.OrderForms[0].Shipments.Count > 0) { ship = cart.OrderForms[0].Shipments[0]; } if (ship != null) { // request rates, make sure we request rates not bound to selected delivery method foreach (ShippingMethodDto.ShippingMethodRow row in shippingMethods.ShippingMethod) { shippingMethodsList.Add(GetShippingRateInfo(row, ship)); } } return(shippingMethodsList); }
private IEnumerable <ShippingMethodDto.ShippingMethodRow> GetShippingMethods() { ShippingMethodDto shippingMethodDto = ShippingManager.GetShippingMethodsByMarket(_currentMarket.GetCurrentMarket().MarketId.Value, false); return(shippingMethodDto.ShippingMethod.Rows.OfType <ShippingMethodDto.ShippingMethodRow>()); }
void ProcessDeleteCommand(string[] items) { // load all shipping options ShippingMethodDto dto = ShippingManager.GetShippingMethods(null, true); if (dto != null && dto.ShippingOption.Count > 0) { // delete selected for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { Guid id = new Guid(keys[0]); // delete selected shipping option ShippingMethodDto.ShippingOptionRow[] soRows = (ShippingMethodDto.ShippingOptionRow[])dto.ShippingOption.Select(String.Format("ShippingOptionId='{0}'", id)); if (soRows != null && soRows.Length > 0) { soRows[0].Delete(); } } } if (dto.HasChanges()) { ShippingManager.SaveShipping(dto); } } }
/// <summary> /// Binds the lists. /// </summary> private void BindLists() { // bind shipment packages if (PackageList.Items.Count <= 1) { ShippingMethodDto shippingDto = ShippingManager.GetShippingPackages(); if (shippingDto.Package != null) { foreach (ShippingMethodDto.PackageRow row in shippingDto.Package.Rows) { PackageList.Items.Add(new ListItem(row.Name, row.PackageId.ToString())); } } PackageList.DataBind(); } // bind warehouses if (WarehouseList.Items.Count <= 1) { WarehouseDto dto = WarehouseManager.GetWarehouseDto(); if (dto.Warehouse != null) { foreach (WarehouseDto.WarehouseRow row in dto.Warehouse.Rows) { WarehouseList.Items.Add(new ListItem(row.Name, row.WarehouseId.ToString())); } } WarehouseList.DataBind(); } // bind merchants if (MerchantList.Items.Count <= 1) { CatalogEntryDto merchants = CatalogContext.Current.GetMerchantsDto(); if (merchants.Merchant != null) { foreach (CatalogEntryDto.MerchantRow row in merchants.Merchant.Rows) { MerchantList.Items.Add(new ListItem(row.Name, row.MerchantId.ToString())); } } MerchantList.DataBind(); } // bind tax categories if (TaxList.Items.Count <= 1) { CatalogTaxDto taxes = CatalogTaxManager.GetTaxCategories(); if (taxes.TaxCategory != null) { foreach (CatalogTaxDto.TaxCategoryRow row in taxes.TaxCategory.Rows) { TaxList.Items.Add(new ListItem(row.Name, row.TaxCategoryId.ToString())); } } TaxList.DataBind(); } }
private Guid GetSipMethodByOptionParam(string itemCode) { string paramName = itemCode.Split('_')[0]; ShippingMethodDto dto = ShippingManager.GetShippingMethodsByMarket(MarketId.Default.Value, false); Guid optionParam = dto.ShippingOptionParameter.Where(r => r.Parameter.Contains(paramName)).FirstOrDefault().ShippingOptionId; return(dto.ShippingMethod.Where(r => r.ShippingOptionId == optionParam).FirstOrDefault().ShippingMethodId); }
public static ShippingManager GetInstance() { if (instance == null) { instance = new ShippingManager(); } return(instance); }
public ShippingRate GetRate(Guid methodId, Shipment shipment, ref string message) { if (shipment == null) { return(null); } var shippingMethod = ShippingManager.GetShippingMethod(methodId); if (shippingMethod == null || shippingMethod.ShippingMethod.Count <= 0) { message = string.Format(ErrorMessages.ShippingMethodCouldNotBeLoaded, methodId); return(null); } var shipmentLineItems = Shipment.GetShipmentLineItems(shipment); if (shipmentLineItems.Count == 0) { message = ErrorMessages.ShipmentContainsNoLineItems; return(null); } if (shipment.Parent == null || shipment.Parent.Parent == null) { message = ErrorMessages.OrderFormOrOrderGroupNotFound; return(null); } var orderAddress = shipment.Parent .Parent .OrderAddresses .FirstOrDefault(address => address.Name == shipment.ShippingAddressId); if (orderAddress == null) { message = ErrorMessages.ShipmentAddressNotFound; return(null); } var query = BuildQuery(orderAddress, shippingMethod, shipment, shipmentLineItems); var estimate = _shippingClient.FindAsync <ShipmentEstimate>(query).Result; if (estimate.Success) { return(CreateShippingRate(methodId, shippingMethod, estimate)); } message = estimate.ErrorMessages .Aggregate(new StringBuilder(), (sb, msg) => { sb.Append(msg); sb.AppendLine(); return(sb); }).ToString(); return(null); }
/// <summary> /// Binds the shipping methods list. /// </summary> /// <param name="paymentRow">The payment row.</param> private void BindShippingMethodsList(PaymentMethodDto.PaymentMethodRow paymentRow) { List <ShippingMethodDto.ShippingMethodRow> leftShippings = new List <ShippingMethodDto.ShippingMethodRow>(); List <ShippingMethodDto.ShippingMethodRow> rightShippings = new List <ShippingMethodDto.ShippingMethodRow>(); ShippingMethodDto dto = ShippingManager.GetShippingMethods(paymentRow != null ? paymentRow.LanguageId : LanguageCode, true); bool allToLeft = false; // if true, then add all shipping methods to the left list if (paymentRow != null) { PaymentMethodDto.ShippingPaymentRestrictionRow[] restrictedShippingRows = paymentRow.GetShippingPaymentRestrictionRows(); if (restrictedShippingRows != null && restrictedShippingRows.Length > 0) { foreach (ShippingMethodDto.ShippingMethodRow shippingMethodRow in dto.ShippingMethod) { bool found = false; foreach (PaymentMethodDto.ShippingPaymentRestrictionRow restrictedShippingRow in restrictedShippingRows) { if (shippingMethodRow.ShippingMethodId == restrictedShippingRow.ShippingMethodId) { found = true; break; } } if (found) { rightShippings.Add(shippingMethodRow); } else { leftShippings.Add(shippingMethodRow); } } ShippingMethodsList.LeftDataSource = leftShippings; ShippingMethodsList.RightDataSource = rightShippings; } else { // add all shipping methods to the left list allToLeft = true; } } else { allToLeft = true; } if (allToLeft) { // add all shipping methods to the left list ShippingMethodsList.LeftDataSource = dto.ShippingMethod; } ShippingMethodsList.DataBind(); }
private bool IsValidSingleShippment() { // Check valid line item for Single Shipment if (Cart.OrderForms.Count > 0) { List <string> warehouseCodes = new List <string>(); var lineItems = Cart.OrderForms[0].LineItems; foreach (LineItem lineItem in lineItems) { if (!warehouseCodes.Contains(lineItem.WarehouseCode)) { warehouseCodes.Add(lineItem.WarehouseCode); } } // Cart only has one warehouse instore pickup if (warehouseCodes.Count == 1) { // Shipping method is "In store pickup", add address to Cart & Shipment IWarehouse warehouse = WarehouseHelper.GetWarehouse(warehouseCodes.FirstOrDefault()); if (!warehouse.IsFulfillmentCenter && warehouse.IsPickupLocation) { Shipment.WarehouseCode = warehouse.Code; if (CartHelper.FindAddressByName(warehouse.Name) == null) { var address = warehouse.ContactInformation.ToOrderAddress(); address.Name = warehouse.Name; Cart.OrderAddresses.Add(address); } Shipment.ShippingAddressId = warehouse.Name; Shipment.ShippingMethodName = ShippingManager.PickupShippingMethodName; var instorepickupShippingMethod = ShippingManager.GetShippingMethods("en").ShippingMethod.ToArray().Where(m => m.Name.Equals(ShippingManager.PickupShippingMethodName)).FirstOrDefault(); if (instorepickupShippingMethod != null) { Shipment.ShippingMethodId = instorepickupShippingMethod.ShippingMethodId; } Cart.AcceptChanges(); } } else { foreach (string warehouseCode in warehouseCodes) { IWarehouse warehouse = WarehouseHelper.GetWarehouse(warehouseCode); if (warehouse != null && warehouse.IsPickupLocation) { return(false); } } } } return(true); }
/// <summary> /// Loads the fresh. /// </summary> /// <returns></returns> private ShippingMethodDto LoadFresh() { ShippingMethodDto sm = ShippingManager.GetShippingPackage(PackageId); // persist in session Session[GetPackageSessionKey()] = sm; return(sm); }
/// <summary> /// Loads the fresh. /// </summary> /// <returns></returns> private ShippingMethodDto LoadFresh() { ShippingMethodDto sm = ShippingManager.GetShippingOption(ShippingOptionId, true); // persist in session Session[GetShippingMethodSessionKey()] = sm; return(sm); }
/// <summary> /// Binds the shipping options. /// </summary> /// <param name="language">The language.</param> private void BindShippingOptions(string language) { this.ddlShippingOption.Items.Clear(); ShippingMethodDto sm = ShippingManager.GetShippingMethods(language, true); ddlShippingOption.DataSource = sm.ShippingOption; ddlShippingOption.DataBind(); }
// GET api/shipping public IHttpActionResult Get() { apiResp = new ApiResponse(); var mng = new ShippingManager(); apiResp.Data = mng.RetrieveAll(); return(Ok(apiResp)); }
internal static object GetShippingRates(ShippingManager shippingManager, OrdersManager ordersManager, Guid shoppingCartId, ShippingInfo shippingInfo) { //var availableShippingMethods = new List<IShippingResponse>(); //JMABase.WriteLogFile("SH Count: " + Config.Get<ShippingConfig>().ShippingCarrierProviders.Values.Count().ToString(), "/importErrorLog.txt"); //foreach (var shippingCarrier in Config.Get<ShippingConfig>().ShippingCarrierProviders.Values.Where(x => x.IsActive)) //{ // var carrierProvider = shippingManager.GetShippingCarrierProvider(shippingCarrier.Name); // JMABase.WriteLogFile("Carrier Name: " + shippingCarrier.Name, "/importErrorLog.txt"); // IShippingRequest genericShippingRequest = GenerateShippingRequest(shippingInfo); // JMABase.WriteLogFile("Shipping Country: " + shippingInfo.ShippingToCountry, "/importErrorLog.txt"); // JMABase.WriteLogFile("Shipping zip: " + shippingInfo.ShippingToZip, "/importErrorLog.txt"); // JMABase.WriteLogFile("Cart weight: " + shippingInfo.TotalCartWeight, "/importErrorLog.txt"); // //genericShippingRequest.CartOrder = CartHelper.GetCartOrder(ordersManager, shoppingCartId); // genericShippingRequest.CartOrder = ordersManager.GetCartOrder(shoppingCartId); // ShippingResponseContext shippingContext = carrierProvider.GetServiceRates(genericShippingRequest); // JMABase.WriteLogFile("Cart details: " + genericShippingRequest.CartOrder.Details.Count(), "/importErrorLog.txt"); // JMABase.WriteLogFile("Shipping context error: " + shippingContext.ErrorMessage, "/importErrorLog.txt"); // JMABase.WriteLogFile("Shipping responses: " + shippingContext.ShippingResponses.Count(), "/importErrorLog.txt"); // if (shippingContext.ShippingResponses != null) // { // availableShippingMethods.AddRange(shippingContext.ShippingResponses); // } //} // return availableShippingMethods.OrderBy(x => x.SortOrder).ToList(); List<ShippingMethod> methodsList = new List<ShippingMethod>(); var order = CartHelper.GetCartOrder(ordersManager, shoppingCartId); foreach (var a in shippingManager.GetShippingMethods().OrderBy(a => a.SortOrder)) { string[] sht = a.ShippingLimitToDisplay.Replace("total price:", "").Trim().Split('-'); decimal hLimit = 0; decimal.TryParse(sht[1], out hLimit); decimal lLimit = 0; decimal.TryParse(sht[0], out lLimit); if (hLimit <= order.Total && order.Total >= lLimit) { methodsList.Add(a); } } return methodsList; }
internal static object GetShippingRates(ShippingManager shippingManager, OrdersManager ordersManager, Guid shoppingCartId,ShippingInfo shippingInfo) { var availableShippingMethods = new List<IShippingResponse>(); foreach (var shippingCarrier in Config.Get<ShippingConfig>().ShippingCarrierProviders.Values.Where(x => x.IsActive)) { var carrierProvider = shippingManager.GetShippingCarrierProvider(shippingCarrier.Name); IShippingRequest genericShippingRequest = GenerateShippingRequest(shippingInfo); genericShippingRequest.CartOrder = CartHelper.GetCartOrder(ordersManager, shoppingCartId); ShippingResponseContext shippingContext = carrierProvider.GetServiceRates(genericShippingRequest); if (shippingContext.ShippingResponses != null) { availableShippingMethods.AddRange(shippingContext.ShippingResponses); } } return availableShippingMethods.OrderBy(x => x.SortOrder).ToList(); }