/// <summary> /// Initializes a new instance of the <see cref="OrderApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="umbracoContext"> /// The umbraco context. /// </param> internal OrderApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext) : base(merchelloContext, umbracoContext) { _orderService = merchelloContext.Services.OrderService; _invoiceService = merchelloContext.Services.InvoiceService; _merchello = new MerchelloHelper(merchelloContext.Services); }
/// <summary> /// Initializes a new instance of the <see cref="OrderApiController" /> class. /// </summary> /// <param name="merchelloContext">The merchello context.</param> public OrderApiController(IMerchelloContext merchelloContext) : base(merchelloContext) { _orderService = merchelloContext.Services.OrderService; _invoiceService = merchelloContext.Services.InvoiceService; _merchello = new MerchelloHelper(merchelloContext.Services); }
/// <summary> /// Initializes a new instance of the <see cref="NoteApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> public NoteApiController(IMerchelloContext merchelloContext) : base(merchelloContext) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); _noteService = merchelloContext.Services.NoteService; _merchelloHelper = new MerchelloHelper(merchelloContext.Services); }
/// <summary> /// Initializes a new instance of the <see cref="ProductFilterGroupQuery"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello Context. /// </param> /// <param name="resolver"> /// The resolver. /// </param> internal ProductFilterGroupQuery(IMerchelloContext merchelloContext, EntityCollectionProviderResolver resolver) : base(merchelloContext.Services.EntityCollectionService, merchelloContext.Cache.RequestCache) { Ensure.ParameterNotNull(merchelloContext, "merchelloContext"); Ensure.ParameterNotNull(resolver, "resolver"); this.Initialize(merchelloContext, resolver); }
/// <summary> /// Initializes a new instance of the <see cref="ExportOrdersReportApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> public ExportOrdersReportApiController(IMerchelloContext merchelloContext) : base(merchelloContext) { _invoiceService = merchelloContext.Services.InvoiceService; _merchello = new MerchelloHelper(merchelloContext.Services); }
public override void FixtureSetup() { base.FixtureSetup(); MerchelloContext = new MerchelloContext(new ServiceContext(new PetaPocoUnitOfWorkProvider()), new CacheHelper(new NullCacheProvider(), new NullCacheProvider(), new NullCacheProvider())); PreTestDataWorker.DeleteAllShipCountries(); var defaultCatalog = PreTestDataWorker.WarehouseService.GetDefaultWarehouse().WarehouseCatalogs.FirstOrDefault(); if (defaultCatalog == null) Assert.Ignore("Default WarehouseCatalog is null"); var us = MerchelloContext.Services.StoreSettingService.GetCountryByCode("US"); var usCountry = new ShipCountry(defaultCatalog.Key, us); ((ServiceContext)MerchelloContext.Services).ShipCountryService.Save(usCountry); var key = Core.Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey; var rateTableProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Gateways.Shipping.ResolveByKey(key); rateTableProvider.DeleteAllActiveShipMethods(usCountry); #region Add and configure 3 rate table shipmethods var gwshipMethod1 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, usCountry, "Ground (Vary by Price)"); gwshipMethod1.RateTable.AddRow(0, 10, 25); gwshipMethod1.RateTable.AddRow(10, 15, 30); gwshipMethod1.RateTable.AddRow(15, 25, 35); gwshipMethod1.RateTable.AddRow(25, 60, 40); // total price should be 50M so we should hit this tier gwshipMethod1.RateTable.AddRow(25, 10000, 50); rateTableProvider.SaveShippingGatewayMethod(gwshipMethod1); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="ShippingGatewayApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> public ShippingGatewayApiController(IMerchelloContext merchelloContext) : base(merchelloContext) { _shippingContext = MerchelloContext.Gateways.Shipping; _shipCountryService = ((ServiceContext)MerchelloContext.Services).ShipCountryService; }
/// <summary> /// Initializes a new instance of the <see cref="ProductOptionApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="contentTypeService"> /// Umbraco's <see cref="IContentTypeService"/> /// </param> public ProductOptionApiController(IMerchelloContext merchelloContext, IContentTypeService contentTypeService) : base(merchelloContext) { Mandate.ParameterNotNull(contentTypeService, "contentTypeService"); _contentTypeService = contentTypeService; _productOptionService = merchelloContext.Services.ProductOptionService; }
public ProductDataService(IMerchelloContext merchelloContext) { //TODO Figure out how to get MerchelloContext instantiated before ExamineManager // attempts to interact with the index //Mandate.ParameterNotNull(merchelloContext, "MerchelloContext"); _merchelloContext = merchelloContext; }
/// <summary> /// The currency. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <returns> /// The <see cref="ICurrency"/>. /// </returns> internal static ICurrency Currency(this IInvoice invoice, IMerchelloContext merchelloContext) { var currencyCode = invoice.CurrencyCode(); return !string.IsNullOrEmpty(currencyCode) ? merchelloContext.Services.StoreSettingService.GetCurrencyByCode(currencyCode) : null; }
/// <summary> /// Initializes a new instance of the <see cref="CheckoutRenderControllerBase"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> protected CheckoutRenderControllerBase(IMerchelloContext merchelloContext) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); _storeSettingService = merchelloContext.Services.StoreSettingService; _gatewayContext = merchelloContext.Gateways; this.Initialize(); }
/// <summary> /// Gets a collection of unfulfilled (unshipped) line items /// </summary> /// <param name="order">The <see cref="IOrder"/></param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <param name="items">A collection of <see cref="IOrderLineItem"/></param> /// <returns>The collection of <see cref="IOrderLineItem"/></returns> public static IEnumerable<IOrderLineItem> UnfulfilledItems(this IOrder order, IMerchelloContext merchelloContext, IEnumerable<IOrderLineItem> items) { if (Constants.DefaultKeys.OrderStatus.Fulfilled == order.OrderStatus.Key) return new List<IOrderLineItem>(); var shippableItems = items.Where(x => x.IsShippable() && x.ShipmentKey == null).ToArray(); var inventoryItems = shippableItems.Where(x => x.ExtendedData.GetTrackInventoryValue()).ToArray(); // get the variants to check the inventory var variants = merchelloContext.Services.ProductVariantService.GetByKeys(inventoryItems.Select(x => x.ExtendedData.GetProductVariantKey())).ToArray(); foreach (var item in inventoryItems) { var variant = variants.FirstOrDefault(x => x.Key == item.ExtendedData.GetProductVariantKey()); if (variant == null) continue; // TODO refactor back ordering. //// check inventory //var inventory = variant.CatalogInventories.FirstOrDefault(x => x.CatalogKey == item.ExtendedData.GetWarehouseCatalogKey()); //if (inventory != null) // item.BackOrder = inventory.Count < item.Quantity; } return shippableItems; }
/// <summary> /// Initializes a new instance of the <see cref="AuditLogApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> public AuditLogApiController(IMerchelloContext merchelloContext) : base(merchelloContext) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); _auditLogService = merchelloContext.Services.AuditLogService; _merchelloHelper = new MerchelloHelper(merchelloContext.Services); }
/// <summary> /// Initializes a new instance of the <see cref="RemoveShipmentOrderItemsFromInventoryAndPersistShipmentTask"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="order"> /// The order. /// </param> /// <param name="keysToShip"> /// The keys to ship. /// </param> public RemoveShipmentOrderItemsFromInventoryAndPersistShipmentTask(IMerchelloContext merchelloContext, IOrder order, IEnumerable<Guid> keysToShip) : base(merchelloContext, order, keysToShip) { _productVariantService = MerchelloContext.Services.ProductVariantService; _shipmentService = MerchelloContext.Services.ShipmentService; _orderService = MerchelloContext.Services.OrderService; }
public void Init() { _gatewayProviderService = PreTestDataWorker.GatewayProviderService; _storeSettingService = PreTestDataWorker.StoreSettingService; _shipCountryService = PreTestDataWorker.ShipCountryService; _merchelloContext = new MerchelloContext(new ServiceContext(new PetaPocoUnitOfWorkProvider()), new CacheHelper(new NullCacheProvider(), new NullCacheProvider(), new NullCacheProvider())); _catalog = PreTestDataWorker.WarehouseService.GetDefaultWarehouse().WarehouseCatalogs.FirstOrDefault(); PreTestDataWorker.DeleteAllShipCountries(); var country = _storeSettingService.GetCountryByCode("US"); var shipCountry = new ShipCountry(_catalog.Key, country); _shipCountryService.Save(shipCountry); var shippingProvider = (FixedRateShippingGatewayProvider) _merchelloContext.Gateways.Shipping.CreateInstance(Core.Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey); Assert.NotNull(shippingProvider); var resource = shippingProvider.ListResourcesOffered().FirstOrDefault(); var gatewayShipMethod = shippingProvider.CreateShippingGatewayMethod(resource, shipCountry, "Ground"); shippingProvider.SaveShippingGatewayMethod(gatewayShipMethod); }
/// <summary> /// Initializes a new instance of the <see cref="BraintreePaymentMethodApiService"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="settings"> /// The settings. /// </param> /// <param name="customerApiService"> /// The customer api provider. /// </param> internal BraintreePaymentMethodApiService(IMerchelloContext merchelloContext, BraintreeProviderSettings settings, IBraintreeCustomerApiService customerApiService) : base(merchelloContext, settings) { Mandate.ParameterNotNull(customerApiService, "customerApiProvider"); _braintreeCustomerApiService = customerApiService; }
/// <summary> /// The text. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="area"> /// The area. /// </param> /// <param name="key"> /// The key. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> internal static string Text(IMerchelloContext merchelloContext, string area, string key) { Mandate.ParameterNotNull(merchelloContext, "MerchelloContext"); if (string.IsNullOrEmpty(area) || string.IsNullOrEmpty(key)) return string.Empty; var lang = "en"; try { lang = MerchelloConfiguration.Current.Section.LogLocalization; } catch (Exception) { lang = "en"; } var cacheKey = CacheKeys.GetLocalizationCacheKey(lang); var xdoc = XDocument.Parse((string)merchelloContext.Cache.RuntimeCache.GetCacheItem(cacheKey, () => ui.getLanguageFile(lang).InnerXml), LoadOptions.None); var xArea = xdoc.Descendants("area").FirstOrDefault(x => x.Attribute("alias").Value == area); if (xArea == null) return string.Empty; var xKey = xArea.Descendants("key").FirstOrDefault(x => x.Attribute("alias").Value == key); return xKey == null ? string.Empty : xKey.Value; }
/// <summary> /// Initializes a new instance of the <see cref="ShipmentResultNotifyModelFactory"/> class. /// </summary> /// <param name="merchelloContext"> /// The <see cref="IMerchelloContext"/>. /// </param> public ShipmentResultNotifyModelFactory(IMerchelloContext merchelloContext) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); _invoiceService = merchelloContext.Services.InvoiceService; _orderService = merchelloContext.Services.OrderService; _storeSettingService = merchelloContext.Services.StoreSettingService; }
/// <summary> /// Initializes a new instance of the <see cref="MarketingApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="umbracoContext"> /// The umbraco context. /// </param> internal MarketingApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext) : base(merchelloContext, umbracoContext) { _offerSettingsService = merchelloContext.Services.OfferSettingsService; // TODO - this need to be fixed to make testable this._providerResolver = OfferProviderResolver.Current; }
/// <summary> /// Initializes a new instance of the <see cref="ProductApiController"/> class. /// This is a helper constructor for unit testing /// </summary> /// <param name="merchelloContext"> /// The merchello Context. /// </param> /// <param name="umbracoContext"> /// The umbraco Context. /// </param> internal ProductApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext) : base(merchelloContext, umbracoContext) { _productService = MerchelloContext.Services.ProductService; _productVariantService = MerchelloContext.Services.ProductVariantService; _warehouseService = MerchelloContext.Services.WarehouseService; _merchello = new MerchelloHelper(MerchelloContext.Services); }
/// <summary> /// Initializes a new instance of the <see cref="PaymentProcessor"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param>e /// <param name="request"> /// The request. /// </param> public PaymentProcessor(IMerchelloContext merchelloContext, PaymentRequestDisplay request) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); this._merchelloContext = merchelloContext; this.Initialize(request); }
/// <summary> /// Initializes a new instance of the <see cref="InvoiceApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> public InvoiceApiController(IMerchelloContext merchelloContext) : base(merchelloContext) { _storeSettingService = MerchelloContext.Services.StoreSettingService as StoreSettingService; _invoiceService = merchelloContext.Services.InvoiceService; _noteService = merchelloContext.Services.NoteService; _merchello = new MerchelloHelper(merchelloContext, false); }
/// <summary> /// Initializes a new instance of the <see cref="MerchelloApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="umbracoContext"> /// The umbraco context. /// </param> protected MerchelloApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext) : base(umbracoContext) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); MerchelloContext = merchelloContext; InstanceId = Guid.NewGuid(); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultWarehousePackagingStrategy"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="lineItemCollection"> /// The line item collection. /// </param> /// <param name="destination"> /// The destination. /// </param> /// <param name="versionKey"> /// The version key. /// </param> public DefaultWarehousePackagingStrategy( IMerchelloContext merchelloContext, LineItemCollection lineItemCollection, IAddress destination, Guid versionKey) : base(merchelloContext, lineItemCollection, destination, versionKey) { }
/// <summary> /// Initializes a new instance of the <see cref="MarketingApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> public MarketingApiController(IMerchelloContext merchelloContext) : base(merchelloContext) { _offerSettingsService = merchelloContext.Services.OfferSettingsService; this._providerResolver = OfferProviderResolver.Current; this._componentResolver = OfferComponentResolver.Current; }
/// <summary> /// This is a helper contructor for unit testing /// </summary> internal ShipmentApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext) : base((MerchelloContext) merchelloContext, umbracoContext) { _shipmentService = merchelloContext.Services.ShipmentService; _invoiceService = merchelloContext.Services.InvoiceService; _orderService = merchelloContext.Services.OrderService; _shipMethodService = ((ServiceContext)merchelloContext.Services).ShipMethodService; }
public MerchelloDataService(IMerchelloContext merchelloContext) { ProductDataService = new ProductDataService(merchelloContext); InvoiceDataService = new InvoiceDataService(merchelloContext); OrderDataService = new OrderDataService(merchelloContext); LogService = new MerchelloLogService(); }
/// <summary> /// Prepare an <see cref="IOrder"/> with saving it to the database /// </summary> /// <param name="invoice">The <see cref="IInvoice"/> to base the order or</param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <returns>The <see cref="IOrder"/></returns> public static IOrder PrepareOrder(this IInvoice invoice, IMerchelloContext merchelloContext) { var orderStatus = merchelloContext.Services.OrderService.GetOrderStatusByKey( Constants.DefaultKeys.OrderStatus.NotFulfilled); return invoice.PrepareOrder(merchelloContext, new OrderBuilderChain(orderStatus, invoice)); }
/// <summary> /// Initializes a new instance of the <see cref="PaymentProcessor"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="request"> /// The request. /// </param> public PaymentProcessor(IMerchelloContext merchelloContext, PaymentRequest request) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); _merchelloContext = merchelloContext; Build(request); }
/// <summary> /// Initializes a new instance of the <see cref="PrimedProductFilterGroupTree"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="getAll"> /// A function to get all of the product filter groups. /// </param> internal PrimedProductFilterGroupTree(IMerchelloContext merchelloContext, Func<IEnumerable<IProductFilterGroup>> getAll) { Ensure.ParameterNotNull(merchelloContext, "merchelloContext"); Ensure.ParameterNotNull(getAll, "getAll"); _productService = merchelloContext.Services.ProductService; _getter = getAll; _cache = merchelloContext.Cache.RuntimeCache; }
/// <summary> /// Gets a collection of shipments for an order. /// </summary> /// <param name="order"> /// The order. /// </param> /// <param name="merchelloContext"> /// The <see cref="IMerchelloContext"/>. /// </param> /// <returns> /// The <see cref="IEnumerable{IShipment}"/>. /// </returns> internal static IEnumerable <IShipment> Shipments(this IOrder order, IMerchelloContext merchelloContext) { return(merchelloContext.Services.ShipmentService.GetShipmentsByOrderKey(order.Key)); }
/// <summary> /// Voids a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <param name="payment">The payment to be voided</param> /// <param name="paymentMethodKey">The <see cref="IPaymentGatewayMethod"/> key</param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> internal static IPaymentResult VoidPayment(this IPayment payment, IMerchelloContext merchelloContext, IInvoice invoice, Guid paymentMethodKey, ProcessorArgumentCollection args) { var paymentGatewayMethod = merchelloContext.Gateways.Payment.GetPaymentGatewayMethodByKey(paymentMethodKey); return(paymentGatewayMethod.VoidPayment(invoice, payment, args)); }
/// <summary> /// Initializes a new instance of the <see cref="BackOfficeCheckoutApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> public BackOfficeCheckoutApiController(IMerchelloContext merchelloContext) : base(merchelloContext) { _customerService = merchelloContext.Services.CustomerService; _merchello = new MerchelloHelper(); }
public OrderDataService(IMerchelloContext merchelloContext) { _merchelloContext = merchelloContext; }
/// <summary> /// Returns a collection of <see cref="IInvoice"/>s this <see cref="IPayment"/> has been applied to /// </summary> /// <param name="payment">The <see cref="IPayment"/></param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <returns>A collection of <see cref="IInvoice"/></returns> internal static IEnumerable <IInvoice> AppliedToInvoices(this IPayment payment, IMerchelloContext merchelloContext) { return(merchelloContext.Services.InvoiceService.GetInvoicesByPaymentKey(payment.Key)); }
/// <summary> /// Initializes a new instance of the <see cref="SaveProductCopyTask"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="original"> /// The original. /// </param> public SaveProductCopyTask(IMerchelloContext merchelloContext, IProduct original) : base(merchelloContext, original) { }
/// <summary> /// Gets the Merchello <see cref="ICustomer"/> for a given Braintree <see cref="Transaction"/>. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="transaction"> /// The transaction. /// </param> /// <returns> /// The <see cref="ICustomer"/>. /// </returns> public static ICustomer GetCustomerForTransaction(IMerchelloContext merchelloContext, Transaction transaction) { var customerService = merchelloContext.Services.CustomerService; return(customerService.GetByKey(new Guid(transaction.CustomerDetails.Id))); }
/// <summary> /// Initializes a new instance of the <see cref="InvoiceApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="umbracoContext"> /// The umbraco context. /// </param> internal InvoiceApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext) : base(merchelloContext, umbracoContext) { _invoiceService = merchelloContext.Services.InvoiceService; }
/// <summary> /// Empties the basket. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="basket"> /// The basket. /// </param> internal static void Empty(IMerchelloContext merchelloContext, IBasket basket) { basket.Items.Clear(); Save(merchelloContext, basket); }
public SalePreparationMock(IMerchelloContext merchelloContext, IItemCache itemCache, ICustomerBase customer) : base(merchelloContext, itemCache, customer) { }
public CheckoutController(IMerchelloContext merchelloContext) : base(merchelloContext) { }
public BasketController(IMerchelloContext merchelloContext) : base(merchelloContext) { }
/// <summary> /// Gets a collection of unfulfilled (unshipped) line items /// </summary> /// <param name="order">The <see cref="IOrder"/></param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <returns>A collection of <see cref="IOrderLineItem"/></returns> public static IEnumerable <IOrderLineItem> UnfulfilledItems(this IOrder order, IMerchelloContext merchelloContext) { return(order.UnfulfilledItems(merchelloContext, order.Items.Select(x => x as OrderLineItem))); }
/// <summary> /// Gets a collection of unfulfilled (unshipped) line items /// </summary> /// <param name="order">The <see cref="IOrder"/></param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <param name="items">A collection of <see cref="IOrderLineItem"/></param> /// <returns>The collection of <see cref="IOrderLineItem"/></returns> public static IEnumerable <IOrderLineItem> UnfulfilledItems(this IOrder order, IMerchelloContext merchelloContext, IEnumerable <IOrderLineItem> items) { if (Constants.DefaultKeys.OrderStatus.Fulfilled == order.OrderStatus.Key) { return(new List <IOrderLineItem>()); } var shippableItems = items.Where(x => x.IsShippable() && x.ShipmentKey == null).ToArray(); var inventoryItems = shippableItems.Where(x => x.ExtendedData.GetTrackInventoryValue()).ToArray(); // get the variants to check the inventory var variants = merchelloContext.Services.ProductVariantService.GetByKeys(inventoryItems.Select(x => x.ExtendedData.GetProductVariantKey())).ToArray(); foreach (var item in inventoryItems) { var variant = variants.FirstOrDefault(x => x.Key == item.ExtendedData.GetProductVariantKey()); if (variant == null) { continue; } // TODO refactor back ordering. //// check inventory //var inventory = variant.CatalogInventories.FirstOrDefault(x => x.CatalogKey == item.ExtendedData.GetWarehouseCatalogKey()); //if (inventory != null) // item.BackOrder = inventory.Count < item.Quantity; } return(shippableItems); }
/// <summary> /// Initializes a new instance of the <see cref="StaticCustomerCollectionProvider"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="collectionKey"> /// The collection key. /// </param> public StaticCustomerCollectionProvider(IMerchelloContext merchelloContext, Guid collectionKey) : base(merchelloContext, collectionKey) { }
/// <summary> /// Initializes a new instance of the <see cref="BraintreePaymentMethodApiService"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="settings"> /// The settings. /// </param> public BraintreePaymentMethodApiService(IMerchelloContext merchelloContext, BraintreeProviderSettings settings) : this(merchelloContext, settings, new BraintreeCustomerApiService(merchelloContext, settings)) { }
/// <summary> /// Initializes a new instance of the <see cref="AddShippableOrderLineItemsToShipmentTask"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="order"> /// The order. /// </param> /// <param name="keysToShip"> /// The keys To Ship. /// </param> public AddShippableOrderLineItemsToShipmentTask(IMerchelloContext merchelloContext, IOrder order, IEnumerable <Guid> keysToShip) : base(merchelloContext, order, keysToShip) { }
/// <summary> /// Initializes a new instance of the <see cref="CustomerItemCacheValidationChain"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> public CustomerItemCacheValidationChain(IMerchelloContext merchelloContext) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); _merchelloContext = merchelloContext; ResolveChain(Core.Constants.TaskChainAlias.ItemCacheValidation); }
/// <summary> /// Purges persisted checkout information /// </summary> /// <param name="merchelloContext"> /// The merchello Context. /// </param> /// <param name="customer"> /// The customer. /// </param> /// <param name="raiseEvents"> /// The raise Events. /// </param> private static void Reset(IMerchelloContext merchelloContext, ICustomerBase customer, bool raiseEvents = true) { customer.ExtendedData.RemoveValue(Core.Constants.ExtendedDataKeys.ShippingDestinationAddress); customer.ExtendedData.RemoveValue(Core.Constants.ExtendedDataKeys.BillingAddress); SaveCustomer(merchelloContext, customer, raiseEvents); }
/// <summary> /// Returns a <see cref="IShipmentRateQuote"/> for a <see cref="IShipment"/> given the 'unique' key of the <see cref="IShipMethod"/> /// </summary> /// <param name="shipment">The <see cref="IShipment"/></param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <param name="shipMethodKey">The GUID key of the <see cref="IShipMethod"/></param> /// <returns>The <see cref="IShipmentRateQuote"/> for the shipment by the specific <see cref="IShipMethod"/> specified</returns> internal static IShipmentRateQuote ShipmentRateQuoteByShipMethod(this IShipment shipment, IMerchelloContext merchelloContext, Guid shipMethodKey) { var shipMethod = ((ServiceContext)merchelloContext.Services).ShipMethodService.GetByKey(shipMethodKey); if (shipMethod == null) { return(null); } // Get the gateway provider to generate the shipment rate quote var provider = merchelloContext.Gateways.Shipping.GetProviderByKey(shipMethod.ProviderKey); // get the GatewayShipMethod from the provider var gatewayShipMethod = provider.GetShippingGatewayMethodsForShipment(shipment).FirstOrDefault(x => x.ShipMethod.Key == shipMethodKey); return(gatewayShipMethod == null ? null : provider.QuoteShipMethodForShipment(shipment, gatewayShipMethod)); }
/// <summary> /// Initializes a new instance of the <see cref="CustomerDataService"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> public CustomerDataService(IMerchelloContext merchelloContext) { _merchelloContext = merchelloContext; }
/// <summary> /// The shipment rate quotes. /// </summary> /// <param name="shipment"> /// The shipment. /// </param> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="tryGetCached"> /// If set true the strategy will try to get a quote from cache /// </param> /// <returns> /// The collection of <see cref="IShipmentRateQuote"/> /// </returns> internal static IEnumerable <IShipmentRateQuote> ShipmentRateQuotes(this IShipment shipment, IMerchelloContext merchelloContext, bool tryGetCached = true) { return(merchelloContext.Gateways.Shipping.GetShipRateQuotesForShipment(shipment, tryGetCached)); }
/// <summary> /// Initializes a new instance of the <see cref="ProductVariantDataModifierChain"/> class. /// </summary> /// <param name="merchelloContext"> /// The <see cref="MerchelloContext"/>. /// </param> public ProductVariantDataModifierChain(IMerchelloContext merchelloContext) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); this._merchelloContext = merchelloContext; this.ResolveChain(Core.Constants.TaskChainAlias.MerchelloHelperProductDataModifiers); }
/// <summary> /// Gets a <see cref="ICheckoutManagerBase"/> for the basket. /// </summary> /// <param name="basket"> /// The basket. /// </param> /// <param name="merchelloContext"> /// The merchello Context. /// </param> /// <param name="settings"> /// The checkout context version change settings. /// </param> /// <returns> /// The <see cref="ICheckoutManagerBase"/>. /// </returns> internal static ICheckoutManagerBase GetCheckoutManager(this IBasket basket, IMerchelloContext merchelloContext, ICheckoutContextSettings settings) { return(new BasketCheckoutManager(basket.CreateCheckoutContext(merchelloContext, settings))); }
/// <summary> /// Returns a collection of <see cref="IAppliedPayment"/> for this <see cref="IPayment"/> /// </summary> /// <param name="payment">The <see cref="IPayment"/></param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <returns>A collection of <see cref="IAppliedPayment"/></returns> internal static IEnumerable <IAppliedPayment> AppliedPayments(this IPayment payment, IMerchelloContext merchelloContext) { return(payment.AppliedPayments(merchelloContext.Services.GatewayProviderService)); }
internal static BasketSalePreparation SalePreparation(this IBasket basket, IMerchelloContext merchelloContext) { return(BasketSalePreparation.GetBasketCheckoutPreparation(merchelloContext, basket)); }
public SiteApiController(IMerchelloContext merchelloContext) { _merchelloContext = merchelloContext; }
/// <summary> /// Packages a basket into one or more shipments. /// </summary> /// <param name="basket"> /// The basket. /// </param> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="destination"> /// The destination. /// </param> /// <param name="strategy"> /// The strategy. /// </param> /// <returns> /// The collection of <see cref="IShipment"/>. /// </returns> internal static IEnumerable <IShipment> PackageBasket(this IBasket basket, IMerchelloContext merchelloContext, IAddress destination, PackagingStrategyBase strategy) { return(!basket.Items.Any() ? new List <IShipment>() : strategy.PackageShipments()); }
/// <summary> /// Gets the <see cref="IInvoice"/> for the <see cref="IOrder"/>. /// </summary> /// <param name="order"> /// The <see cref="IOrder"/>. /// </param> /// <param name="merchelloContext"> /// The <see cref="IMerchelloContext"/>. /// </param> /// <returns> /// The <see cref="IInvoice"/>. /// </returns> internal static IInvoice Invoice(this IOrder order, IMerchelloContext merchelloContext) { return(merchelloContext.Services.InvoiceService.GetByKey(order.InvoiceKey)); }
/// <summary> /// Initializes a new instance of the <see cref="PaymentApiController"/> class. /// This is a helper contructor for unit testing /// </summary> /// <param name="merchelloContext"> /// The merchello Context. /// </param> /// <param name="umbracoContext"> /// The umbraco Context. /// </param> public PaymentApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext) : base(merchelloContext, umbracoContext) { _paymentService = merchelloContext.Services.PaymentService; _invoiceService = merchelloContext.Services.InvoiceService; }