public static List <PriceAndMarket> GetPricesWithMarket(this VariationContent content, IMarket market)
        {
            List <PriceAndMarket>  priceAndMarkets = new List <PriceAndMarket>();
            ItemCollection <Price> itemCollection  = null;

            try
            {
                itemCollection = content.GetPrices();
            }
            catch (Exception ex)
            {
                Log.Error("GetPrices returned an error at product with id " + content.Code, ex);
            }
            if (itemCollection != null)
            {
                foreach (var price in itemCollection)
                {
                    priceAndMarkets.Add(new PriceAndMarket()
                    {
                        MarkedId       = price.MarketId.Value,
                        PriceTypeId    = price.CustomerPricing.PriceTypeId.ToString(),
                        PriceCode      = price.CustomerPricing.PriceCode,
                        Price          = GetPriceString(price),
                        CurrencyCode   = price.UnitPrice.Currency.CurrencyCode,
                        CurrencySymbol = price.UnitPrice.Currency.Format.CurrencySymbol//Pricecode??
                    });
                }
            }
            return(priceAndMarkets);
        }
예제 #2
0
        public IEnumerable <CartItem> GetCartItems()
        {
            if (_cardhelper.IsEmpty)
            {
                return(Enumerable.Empty <CartItem>());
            }

            var cartItems = new List <CartItem>();
            var lineItems = _cardhelper.Cart.GetAllLineItems();

            //// In order to show the images for the items in the cart, we need to load the variants
            var variants = _contentLoader.GetItems(lineItems.Select(x => _referenceConverter.GetContentLink(x.Code)),
                                                   _preferredCulture).OfType <VariationContent>();

            foreach (var lineItem in lineItems)
            {
                VariationContent variant = variants.FirstOrDefault(x => x.Code == lineItem.Code);
                ProductContent   product = _contentLoader.Get <ProductContent>(variant.GetParentProducts().FirstOrDefault());
                CartItem         item    = new CartItem
                {
                    Code        = lineItem.Code,
                    DisplayName = lineItem.DisplayName,
                    ImageUrl    = variant.GetAssets <IContentImage>(_contentLoader, _urlResolver).FirstOrDefault() ?? "",
                    Quantity    = lineItem.Quantity,
                    Url         = lineItem.GetUrl(),
                    Variant     = variant,
                    Price       = variant.GetPrices().FirstOrDefault().UnitPrice
                };
                cartItems.Add(item);
            }

            return(cartItems);
        }
예제 #3
0
        protected bool HasPrice(VariationContent variationContent)
        {
            var price = variationContent.GetPrices(PricingLoader).FirstOrDefault(x => x.MarketId == CurrentMarket.GetCurrentMarket().MarketId);

            return(price != null &&
                   price.UnitPrice != null);
        }
        Injected <PricingLoader> rwPriceLoader;         // just to show
                                                        //Injected<ICurrentMarket> currentMarketService;
                                                        //Injected<ReferenceConverter> _refConv;


        // Fund: Pricing Extensions
        private void CheckPrices(VariationContent currentContent)
        {
            // Don't want to see the below lines
            //StoreHelper.GetBasePrice(currentContent.LoadEntry());
            // StoreHelper.GetSalePrice(currentContent.LoadEntry(), 11, theMarket, new Currency("USD")); // Get currency from market or thread... or something

            IMarket theMarket = _currentMarket.GetCurrentMarket();

            var priceRef           = currentContent.PriceReference;    // a ContentReference
            var gotPrices          = currentContent.GetPrices();       // Gets all, recieve "Specialized" Price/ItemCollection
            var defaultPrice       = currentContent.GetDefaultPrice(); // All Cust + qty 0 ... market sensitive
            var custSpecificPrices = currentContent.GetCustomerPrices();

            var PriceCheck = (IPricing)currentContent; // null if not a SKU

            var p1 = roPriceLoader.Service.GetPrices(
                currentContent.ContentLink
                , MarketId.Default
                , new CustomerPricing(CustomerPricing.PriceType.PriceGroup, "VIP"));
            // arbitrary Price-Group, could read
            // ...CustomerContext.Current.CurrentContact.EffectiveCustomerGroup;

            var p2 = roPriceLoader.Service.GetCustomerPrices(
                currentContent.ContentLink
                , theMarket.DefaultCurrency // ...or something
                , 8M
                , true);                    // bool - return customer pricing

            // Loader examples "Infrastructure/PriceCalculator"
        }
예제 #5
0
        /// <summary>
        /// Gets price information for a variation as a Price object. You can get the monetary price from the UnitPrice member.
        /// </summary>
        /// <param name="variation">The variation.</param>
        /// <param name="market">The market.</param>
        /// <returns></returns>
        public static Price GetDefaultPriceMoney(this VariationContent variation, IMarket market = null)
        {
            var prices = variation.GetPrices();

            if (prices != null)
            {
                if (market != null)
                {
                    return(prices.FirstOrDefault(x => x.MarketId.Equals(market.MarketId) && x.UnitPrice.Currency == market.DefaultCurrency && x.CustomerPricing.PriceTypeId == CustomerPricing.PriceType.AllCustomers));
                }
                return(prices.FirstOrDefault(x => x.CustomerPricing.PriceTypeId == CustomerPricing.PriceType.AllCustomers));
            }
            return(null);
        }
예제 #6
0
        public static Price GetDefautPriceMoney(this VariationContent variation, IMarket market = null)
        {
            ReadOnlyPricingLoader pricingLoader = ServiceLocator.Current.GetInstance <ReadOnlyPricingLoader>();

            ItemCollection <Price> prices;

            prices = variation.GetPrices();

            if (prices != null)
            {
                if (market != null)
                {
                    return(prices.FirstOrDefault(x => x.MarketId.Equals(market.MarketId) && x.UnitPrice.Currency == market.DefaultCurrency && x.CustomerPricing.PriceTypeId == CustomerPricing.PriceType.AllCustomers));
                }
                return(prices.FirstOrDefault(x => x.CustomerPricing.PriceTypeId == CustomerPricing.PriceType.AllCustomers));
            }
            return(null);
        }
예제 #7
0
        public static Price GetCustomerClubPrice(this VariationContent variation, IMarket market)
        {
            var prices = variation.GetPrices();

            Func <Price, bool> priceFilter = delegate(Price d)
            {
                return(d.CustomerPricing.PriceCode != string.Empty &&
                       (d.CustomerPricing.PriceTypeId == CustomerPricing.PriceType.PriceGroup &&
                        d.CustomerPricing.PriceCode == Constants.CustomerGroup.CustomerClub));
            };

            if (prices.Any())
            {
                var price = prices.FirstOrDefault(priceFilter);
                return(price);
            }

            return(null);
        }
        // Fund: Pricing Extensions // more of pricing in /Pricing/PricingService...
        private void CheckPrices(VariationContent currentContent)
        {
            /**/
            //currentContent.getp
            Entry e = CatalogContext.Current.GetCatalogEntry(currentContent.Code);
            var   p = e.PriceValues; // gets 5

            IEnumerable <CatalogEntryDto.SalePriceRow> rows = CatalogContext.Current.GetCatalogEntryDto
                                                                  (currentContent.Code, new CatalogEntryResponseGroup
                                                                      (CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull)).SalePrice; // zero rows
            /**/

            var salePrice     = StoreHelper.GetSalePrice(currentContent.LoadEntry(), 7);
            var discountPrice = StoreHelper.GetDiscountPrice(currentContent.LoadEntry());

            var priceRef = currentContent.PriceReference; // a ContentReference

            EPiServer.Commerce.SpecializedProperties.ItemCollection <EPiServer.Commerce.SpecializedProperties.Price>
            gotPrices = currentContent.GetPrices();              // Gets all, recieve "Specialized" Price

            var defaultPrice = currentContent.GetDefaultPrice(); // All Cust + qty 0 ... market sensitive

            var custPrices = currentContent.GetCustomerPrices(
                new Currency("USD")
                , 3M
                , true); // for the current user - fourth arg is the PriceLoader - remember EffectivePriceGroup

            // the below includes TaxCategory
            var PriceStuff = (IPricing)currentContent; // null if "a price" is N/A,

            // not extensions, fairly full view of prices
            PricingService myPricing = new PricingService(
                _priceService, _currentMarket, _priceDetailService);

            //myPricing.CheckPrices(currentContent);
            //myPricing.GetPrices(currentContent.Code);
        }