public virtual PriceCalculationOptions CreateDefaultOptions(
            bool forListing,
            Customer customer                = null,
            Currency targetCurrency          = null,
            ProductBatchContext batchContext = null)
        {
            customer ??= batchContext?.Customer ?? _workContext.CurrentCustomer;

            var store        = batchContext?.Store ?? _storeContext.CurrentStore;
            var language     = _workContext.WorkingLanguage;
            var priceDisplay = _catalogSettings.PriceDisplayType;
            var taxInclusive = _workContext.GetTaxDisplayTypeFor(customer, store.Id) == TaxDisplayType.IncludingTax;
            var determinePreselectedPrice = forListing && priceDisplay == PriceDisplayType.PreSelectedPrice;

            targetCurrency ??= _workContext.WorkingCurrency;
            batchContext ??= _productService.CreateProductBatchContext(null, store, customer, false);

            var options = new PriceCalculationOptions(batchContext, customer, store, language, targetCurrency)
            {
                IsGrossPrice = _taxSettings.PricesIncludeTax,
                TaxInclusive = taxInclusive,
                IgnorePercentageDiscountOnTierPrices = !_catalogSettings.ApplyPercentageDiscountOnTierPrice,
                IgnorePercentageTierPricesOnAttributePriceAdjustments = !_catalogSettings.ApplyTierPricePercentageToAttributePriceAdjustments,
                IgnoreDiscounts            = forListing && priceDisplay == PriceDisplayType.PriceWithoutDiscountsAndAttributes,
                DetermineLowestPrice       = forListing && priceDisplay == PriceDisplayType.LowestPrice,
                DeterminePreselectedPrice  = determinePreselectedPrice,
                ApplyPreselectedAttributes = determinePreselectedPrice,
                TaxFormat        = _currencyService.GetTaxFormat(null, taxInclusive, PricingTarget.Product, language),
                PriceRangeFormat = T("Products.PriceRangeFrom").Value,
                RoundingCurrency = targetCurrency == _primaryCurrency ? _workContext.WorkingCurrency : targetCurrency
            };

            return(options);
        }
Ejemplo n.º 2
0
        public ActionResult Footer()
        {
            string taxInfo = (_workContext.GetTaxDisplayTypeFor(_workContext.CurrentCustomer, _storeContext.CurrentStore.Id) == TaxDisplayType.IncludingTax)
                ? T("Tax.InclVAT")
                : T("Tax.ExclVAT");

            string shippingInfoLink = Url.RouteUrl("Topic", new { SystemName = "shippinginfo" });
            var    store            = _storeContext.CurrentStore;

            var AvailableStoreThemes = _themeRegistry.GetThemeManifests()
                                       .Where(x => !x.MobileTheme)
                                       .Select(x =>
            {
                return(new StoreThemeModel()
                {
                    Name = x.ThemeName,
                    Title = x.ThemeTitle
                });
            })
                                       .ToList();

            var model = new FooterModel()
            {
                StoreName           = store.Name,
                LegalInfo           = T("Tax.LegalInfoFooter", taxInfo, shippingInfoLink),
                ShowLegalInfo       = _taxSettings.ShowLegalHintsInFooter,
                ShowThemeSelector   = _themeSettings.AllowCustomerToSelectTheme && AvailableStoreThemes.Count > 1,
                BlogEnabled         = _blogSettings.Enabled,
                ForumEnabled        = _forumSettings.ForumsEnabled,
                HideNewsletterBlock = _customerSettings.HideNewsletterBlock,
            };

            var hint = _settingService.GetSettingByKey <string>("Rnd_SmCopyrightHint", string.Empty, store.Id);

            if (hint.IsEmpty())
            {
                hint = s_hints[new Random().Next(s_hints.Length)];
                _settingService.SetSetting <string>("Rnd_SmCopyrightHint", hint, store.Id);
            }

            var topics = new string[] { "paymentinfo", "imprint", "disclaimer" };

            foreach (var t in topics)
            {
                //load by store
                var topic = _topicService.GetTopicBySystemName(t, store.Id);
                if (topic == null)
                {
                    //not found. let's find topic assigned to all stores
                    topic = _topicService.GetTopicBySystemName(t, 0);
                }

                if (topic != null)
                {
                    model.Topics.Add(t, topic.Title);
                }
            }

            var socialSettings = EngineContext.Current.Resolve <SocialSettings>();

            model.ShowSocialLinks = socialSettings.ShowSocialLinksInFooter;
            model.FacebookLink    = socialSettings.FacebookLink;
            model.GooglePlusLink  = socialSettings.GooglePlusLink;
            model.TwitterLink     = socialSettings.TwitterLink;
            model.PinterestLink   = socialSettings.PinterestLink;
            model.YoutubeLink     = socialSettings.YoutubeLink;
            model.SmartStoreHint  = "<a href='http://www.smartstore.com/net' class='sm-hint' target='_blank'><strong>{0}</strong></a> by SmartStore AG &copy; {1}".FormatCurrent(hint, DateTime.Now.Year);

            return(PartialView(model));
        }