public void Can_save_and_load_checkoutAttributeValue()
        {
            var cav = new CheckoutAttributeValue()
            {
                Name              = "Name 2",
                PriceAdjustment   = 1.1M,
                WeightAdjustment  = 2.1M,
                IsPreSelected     = true,
                DisplayOrder      = 3,
                CheckoutAttribute = new CheckoutAttribute
                {
                    Name       = "Name 1",
                    TextPrompt = "TextPrompt 1",
                    IsRequired = true,
                    ShippableProductRequired = true,
                    IsTaxExempt          = true,
                    TaxCategoryId        = 1,
                    AttributeControlType = AttributeControlType.Datepicker,
                    DisplayOrder         = 2
                }
            };

            var fromDb = SaveAndLoadEntity(cav);

            fromDb.ShouldNotBeNull();
            fromDb.Name.ShouldEqual("Name 2");
            fromDb.PriceAdjustment.ShouldEqual(1.1M);
            fromDb.WeightAdjustment.ShouldEqual(2.1M);
            fromDb.IsPreSelected.ShouldEqual(true);
            fromDb.DisplayOrder.ShouldEqual(3);

            fromDb.CheckoutAttribute.ShouldNotBeNull();
            fromDb.CheckoutAttribute.Name.ShouldEqual("Name 1");
        }
Exemplo n.º 2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                var checkoutAttribute = this.CheckoutAttributeService.GetCheckoutAttributeById(this.CheckoutAttributeId);
                if (checkoutAttribute != null)
                {
                    var cav = new CheckoutAttributeValue()
                    {
                        CheckoutAttributeId = checkoutAttribute.CheckoutAttributeId,
                        Name             = txtNewName.Text,
                        PriceAdjustment  = txtNewPriceAdjustment.Value,
                        WeightAdjustment = txtNewWeightAdjustment.Value,
                        IsPreSelected    = cbNewIsPreSelected.Checked,
                        DisplayOrder     = txtNewDisplayOrder.Value
                    };
                    this.CheckoutAttributeService.InsertCheckoutAttributeValue(cav);

                    SaveLocalizableContent(cav);

                    string url = string.Format("CheckoutAttributeDetails.aspx?CheckoutAttributeID={0}&TabID={1}", checkoutAttribute.CheckoutAttributeId, "pnlValues");
                    Response.Redirect(url);
                }
            }
            catch (Exception exc)
            {
                processAjaxError(exc);
            }
        }
        public IActionResult ValueCreatePopup(CheckoutAttributeValueModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes))
            {
                return(AccessDeniedView());
            }

            var checkoutAttribute = _checkoutAttributeService.GetCheckoutAttributeById(model.CheckoutAttributeId);

            if (checkoutAttribute == null)
            {
                //No checkout attribute found with the specified id
                return(RedirectToAction("List"));
            }

            model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
            model.BaseWeightIn             = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId).Name;

            if (checkoutAttribute.AttributeControlType == AttributeControlType.ColorSquares)
            {
                //ensure valid color is chosen/entered
                if (String.IsNullOrEmpty(model.ColorSquaresRgb))
                {
                    ModelState.AddModelError("", "Color is required");
                }
                //TO DO
                //try
                //{
                //    //ensure color is valid (can be instanciated)
                //    System.Drawing.ColorTranslator.FromHtml(model.ColorSquaresRgb);
                //}
                //catch (Exception exc)
                //{
                //    ModelState.AddModelError("", exc.Message);
                //}
            }

            if (ModelState.IsValid)
            {
                var cav = new CheckoutAttributeValue
                {
                    CheckoutAttributeId = model.CheckoutAttributeId,
                    Name             = model.Name,
                    ColorSquaresRgb  = model.ColorSquaresRgb,
                    PriceAdjustment  = model.PriceAdjustment,
                    WeightAdjustment = model.WeightAdjustment,
                    IsPreSelected    = model.IsPreSelected,
                    DisplayOrder     = model.DisplayOrder,
                };
                cav.Locales = UpdateValueLocales(cav, model);
                checkoutAttribute.CheckoutAttributeValues.Add(cav);
                _checkoutAttributeService.UpdateCheckoutAttribute(checkoutAttribute);

                ViewBag.RefreshPage = true;
                return(View(model));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets checkout attribute value price
        /// </summary>
        /// <param name="cav">Checkout attribute value</param>
        /// <param name="customer">Customer</param>
        /// <returns>Price</returns>
        public static decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav,
                                                        Customer customer)
        {
            string error = string.Empty;

            return(GetCheckoutAttributePrice(cav, customer, ref error));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets checkout attribute value price
        /// </summary>
        /// <param name="cav">Checkout attribute value</param>
        /// <param name="includingTax">A value indicating whether calculated price should include tax</param>
        /// <param name="customer">Customer</param>
        /// <returns>Price</returns>
        public virtual decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav,
                                                         bool includingTax, Customer customer)
        {
            decimal taxRate = decimal.Zero;

            return(GetCheckoutAttributePrice(cav, includingTax, customer, out taxRate));
        }
        public virtual void UpdateCheckoutAttributeValue(CheckoutAttributeValue checkoutAttributeValue)
        {
            if (checkoutAttributeValue == null)
            {
                throw new ArgumentNullException("checkoutAttributeValue");
            }

            _checkoutAttributeValueRepository.Update(checkoutAttributeValue);
        }
Exemplo n.º 7
0
        ///// <summary>
        /////     Gets checkout attribute value price
        ///// </summary>
        ///// <param name="cav">Checkout attribute value</param>
        ///// <returns>Price</returns>
        //public virtual decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav)
        //{
        //    var customer = _workContext.CurrentCustomer;
        //    return GetCheckoutAttributePrice(cav, customer);
        //}

        /// <summary>
        ///     Gets checkout attribute value price
        /// </summary>
        /// <param name="cav">Checkout attribute value</param>
        /// <param name="customer">Customer</param>
        /// <returns>Price</returns>
        public virtual decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav, User customer)
        {
            //var includingTax = _workContext.TaxDisplayType == TaxDisplayType.IncludingTax;

            var taxDisplayType = TaxSettings.TaxDisplayType;
            var includingTax   = taxDisplayType == TaxDisplayType.IncludingTax;

            return(GetCheckoutAttributePrice(cav, includingTax, customer));
        }
        protected void SaveLocalizableContentGrid(CheckoutAttributeValue cav)
        {
            if (cav == null)
            {
                return;
            }

            if (!this.HasLocalizableContent)
            {
                return;
            }

            foreach (GridViewRow row in gvValues.Rows)
            {
                Repeater rptrLanguageDivs2 = row.FindControl("rptrLanguageDivs2") as Repeater;
                if (rptrLanguageDivs2 != null)
                {
                    HiddenField hfCheckoutAttributeValueId = row.FindControl("hfCheckoutAttributeValueId") as HiddenField;
                    int         cavId = int.Parse(hfCheckoutAttributeValueId.Value);
                    if (cavId == cav.CheckoutAttributeValueId)
                    {
                        foreach (RepeaterItem item in rptrLanguageDivs2.Items)
                        {
                            if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                            {
                                var txtLocalizedName = (TextBox)item.FindControl("txtLocalizedName");
                                var lblLanguageId    = (Label)item.FindControl("lblLanguageId");

                                int    languageId = int.Parse(lblLanguageId.Text);
                                string name       = txtLocalizedName.Text;

                                bool allFieldsAreEmpty = string.IsNullOrEmpty(name);

                                var content = CheckoutAttributeManager.GetCheckoutAttributeValueLocalizedByCheckoutAttributeValueIdAndLanguageId(cav.CheckoutAttributeValueId, languageId);
                                if (content == null)
                                {
                                    if (!allFieldsAreEmpty && languageId > 0)
                                    {
                                        //only insert if one of the fields are filled out (avoid too many empty records in db...)
                                        content = CheckoutAttributeManager.InsertCheckoutAttributeValueLocalized(cav.CheckoutAttributeValueId,
                                                                                                                 languageId, name);
                                    }
                                }
                                else
                                {
                                    if (languageId > 0)
                                    {
                                        content = CheckoutAttributeManager.UpdateCheckoutAttributeValueLocalized(content.CheckoutAttributeValueLocalizedId,
                                                                                                                 content.CheckoutAttributeValueId, languageId, name);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Inserts a checkout attribute value
        /// </summary>
        /// <param name="checkoutAttributeValue">Checkout attribute value</param>
        public virtual void InsertCheckoutAttributeValue(CheckoutAttributeValue checkoutAttributeValue)
        {
            if (checkoutAttributeValue == null)
            {
                throw new ArgumentNullException("checkoutAttributeValue");
            }

            _checkoutAttributeValueRepository.Insert(checkoutAttributeValue);
            //_unitOfWork.Commit();
        }
 protected virtual async Task UpdateValueLocalesAsync(CheckoutAttributeValue checkoutAttributeValue, CheckoutAttributeValueModel model)
 {
     foreach (var localized in model.Locales)
     {
         await _localizedEntityService.SaveLocalizedValueAsync(checkoutAttributeValue,
                                                               x => x.Name,
                                                               localized.Name,
                                                               localized.LanguageId);
     }
 }
Exemplo n.º 11
0
 protected virtual void UpdateValueLocales(CheckoutAttributeValue checkoutAttributeValue, CheckoutAttributeValueModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(checkoutAttributeValue,
                                                    x => x.Name,
                                                    localized.Name,
                                                    localized.LanguageId);
     }
 }
Exemplo n.º 12
0
        public virtual void InsertCheckoutAttributeValue(CheckoutAttributeValue checkoutAttributeValue)
        {
            if (checkoutAttributeValue == null)
            {
                throw new ArgumentNullException("checkoutAttributeValue");
            }

            _checkoutAttributeValueRepository.Insert(checkoutAttributeValue);

            //event notification
            _eventPublisher.EntityInserted(checkoutAttributeValue);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Updates the checkout attribute value
        /// </summary>
        /// <param name="checkoutAttributeValue">Checkout attribute value</param>
        public virtual void UpdateCheckoutAttributeValue(CheckoutAttributeValue checkoutAttributeValue)
        {
            if (checkoutAttributeValue == null)
            {
                throw new ArgumentNullException(nameof(checkoutAttributeValue));
            }

            _checkoutAttributeValueRepository.Update(checkoutAttributeValue);

            //event notification
            _eventPublisher.EntityUpdated(checkoutAttributeValue);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Updates the checkout attribute value
        /// </summary>
        /// <param name="checkoutAttributeValue">Checkout attribute value</param>
        public virtual void UpdateCheckoutAttributeValue(CheckoutAttributeValue checkoutAttributeValue)
        {
            if (checkoutAttributeValue == null)
                throw new ArgumentNullException("checkoutAttributeValue");

            _checkoutAttributeValueRepository.Update(checkoutAttributeValue);

            _cacheManager.RemoveByPattern(CHECKOUTATTRIBUTES_PATTERN_KEY);
            _cacheManager.RemoveByPattern(CHECKOUTATTRIBUTEVALUES_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityUpdated(checkoutAttributeValue);
        }
Exemplo n.º 15
0
        protected void SaveLocalizableContent(CheckoutAttributeValue cav)
        {
            if (cav == null)
            {
                return;
            }

            if (!this.HasLocalizableContent)
            {
                return;
            }

            foreach (RepeaterItem item in rptrLanguageDivs.Items)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    var txtNewLocalizedName = (TextBox)item.FindControl("txtNewLocalizedName");
                    var lblLanguageId       = (Label)item.FindControl("lblLanguageId");

                    int    languageId = int.Parse(lblLanguageId.Text);
                    string name       = txtNewLocalizedName.Text;

                    bool allFieldsAreEmpty = string.IsNullOrEmpty(name);

                    var content = this.CheckoutAttributeService.GetCheckoutAttributeValueLocalizedByCheckoutAttributeValueIdAndLanguageId(cav.CheckoutAttributeValueId, languageId);
                    if (content == null)
                    {
                        if (!allFieldsAreEmpty && languageId > 0)
                        {
                            //only insert if one of the fields are filled out (avoid too many empty records in db...)
                            content = new CheckoutAttributeValueLocalized()
                            {
                                CheckoutAttributeValueId = cav.CheckoutAttributeValueId,
                                LanguageId = languageId,
                                Name       = name
                            };
                            this.CheckoutAttributeService.InsertCheckoutAttributeValueLocalized(content);
                        }
                    }
                    else
                    {
                        if (languageId > 0)
                        {
                            content.LanguageId = languageId;
                            content.Name       = name;
                            this.CheckoutAttributeService.UpdateCheckoutAttributeValueLocalized(content);
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Inserts a checkout attribute value
        /// </summary>
        /// <param name="checkoutAttributeValue">Checkout attribute value</param>
        public virtual void InsertCheckoutAttributeValue(CheckoutAttributeValue checkoutAttributeValue)
        {
            if (checkoutAttributeValue == null)
            {
                throw new ArgumentNullException(nameof(checkoutAttributeValue));
            }

            _checkoutAttributeValueRepository.Insert(checkoutAttributeValue);

            _cacheManager.RemoveByPattern(CHECKOUTATTRIBUTES_PATTERN_KEY);
            _cacheManager.RemoveByPattern(CHECKOUTATTRIBUTEVALUES_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityInserted(checkoutAttributeValue);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Inserts a checkout attribute value
        /// </summary>
        /// <param name="checkoutAttributeValue">Checkout attribute value</param>
        public virtual void InsertCheckoutAttributeValue(CheckoutAttributeValue checkoutAttributeValue)
        {
            if (checkoutAttributeValue == null)
            {
                throw new ArgumentNullException(nameof(checkoutAttributeValue));
            }

            _checkoutAttributeValueRepository.Insert(checkoutAttributeValue);

            _cacheManager.RemoveByPattern(NopOrderDefaults.CheckoutAttributesPatternCacheKey);
            _cacheManager.RemoveByPattern(NopOrderDefaults.CheckoutAttributeValuesPatternCacheKey);

            //event notification
            _eventPublisher.EntityInserted(checkoutAttributeValue);
        }
        /// <summary>
        /// Updates the checkout attribute value
        /// </summary>
        /// <param name="checkoutAttributeValue">Checkout attribute value</param>
        public virtual void UpdateCheckoutAttributeValue(CheckoutAttributeValue checkoutAttributeValue)
        {
            if (checkoutAttributeValue == null)
            {
                throw new ArgumentNullException(nameof(checkoutAttributeValue));
            }

            _checkoutAttributeValueRepository.Update(checkoutAttributeValue);

            _cacheManager.RemoveByPrefix(NopOrderDefaults.CheckoutAttributesPrefixCacheKey);
            _cacheManager.RemoveByPrefix(NopOrderDefaults.CheckoutAttributeValuesPrefixCacheKey);

            //event notification
            _eventPublisher.EntityUpdated(checkoutAttributeValue);
        }
        /// <summary>
        /// Updates the checkout attribute value
        /// </summary>
        /// <param name="checkoutAttributeValue">Checkout attribute value</param>
        public virtual void UpdateCheckoutAttributeValue(CheckoutAttributeValue checkoutAttributeValue)
        {
            if (checkoutAttributeValue == null)
            {
                throw new ArgumentNullException("checkoutAttributeValue");
            }

            _checkoutAttributeValueRepository.Update(checkoutAttributeValue);

            _cacheManager.GetCache(CACHE_NAME_CHECKOUTATTRIBUTE).Clear();
            _cacheManager.GetCache(CACHE_NAME_CHECKOUTATTRIBUTEVALUE).Clear();

            //event notification
            //_eventPublisher.EntityUpdated(checkoutAttributeValue);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Gets checkout attribute value price
        /// </summary>
        /// <param name="cav">Checkout attribute value</param>
        /// <param name="customer">Customer</param>
        /// <returns>Price</returns>
        public virtual decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav, Customer customer)
        {
            bool includingTax = false;

            switch (_workContext.TaxDisplayType)
            {
            case TaxDisplayType.ExcludingTax:
                includingTax = false;
                break;

            case TaxDisplayType.IncludingTax:
                includingTax = true;
                break;
            }
            return(GetCheckoutAttributePrice(cav, includingTax, customer));
        }
        protected virtual List <LocalizedProperty> UpdateValueLocales(CheckoutAttributeValue checkoutAttributeValue, CheckoutAttributeValueModel model)
        {
            List <LocalizedProperty> localized = new List <LocalizedProperty>();

            foreach (var local in model.Locales)
            {
                if (!(String.IsNullOrEmpty(local.Name)))
                {
                    localized.Add(new LocalizedProperty()
                    {
                        LanguageId  = local.LanguageId,
                        LocaleKey   = "Name",
                        LocaleValue = local.Name,
                    });
                }
            }
            return(localized);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Gets checkout attribute value price
        /// </summary>
        /// <param name="cav">Checkout attribute value</param>
        /// <param name="customer">Customer</param>
        /// <param name="error">Error</param>
        /// <returns>Price</returns>
        public static decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav,
                                                        Customer customer, ref string error)
        {
            bool includingTax = false;

            switch (NopContext.Current.TaxDisplayType)
            {
            case TaxDisplayTypeEnum.ExcludingTax:
                includingTax = false;
                break;

            case TaxDisplayTypeEnum.IncludingTax:
                includingTax = true;
                break;
            }
            return(GetCheckoutAttributePrice(cav,
                                             includingTax, customer, ref error));
        }
Exemplo n.º 23
0
        public virtual async Task <Tax> CalculateCheckoutAttributeTaxAsync(
            CheckoutAttributeValue attributeValue,
            bool?inclusive    = null,
            Customer customer = null,
            Currency currency = null)
        {
            Guard.NotNull(attributeValue, nameof(attributeValue));

            await _db.LoadReferenceAsync(attributeValue, x => x.CheckoutAttribute);

            var attribute = attributeValue.CheckoutAttribute;

            if (attribute.IsTaxExempt)
            {
                return(new Tax(TaxRate.Zero, 0m, 0m, true, true, currency));
            }

            return(await CalculateTaxAsync(null, attributeValue.PriceAdjustment, _taxSettings.PricesIncludeTax, attribute.TaxCategoryId, inclusive, customer, currency));
        }
Exemplo n.º 24
0
        /// <summary>
        /// Gets checkout attribute value price
        /// </summary>
        /// <param name="ca">Checkout attribute</param>
        /// <param name="cav">Checkout attribute value</param>
        /// <param name="includingTax">A value indicating whether calculated price should include tax</param>
        /// <param name="customer">Customer</param>
        /// <param name="taxRate">Tax rate</param>
        /// <returns>Price</returns>
        public virtual decimal GetCheckoutAttributePrice(CheckoutAttribute ca, CheckoutAttributeValue cav,
            bool includingTax, Customer customer, out decimal taxRate)
        {
            if (cav == null)
                throw new ArgumentNullException(nameof(cav));

            taxRate = decimal.Zero;

            var price = cav.PriceAdjustment;
            if (ca.IsTaxExempt)
            {
                return price;
            }

            var priceIncludesTax = _taxSettings.PricesIncludeTax;
            var taxClassId = ca.TaxCategoryId;
            return GetProductPrice(null, taxClassId, price, includingTax, customer,
                priceIncludesTax, out taxRate);
        }
Exemplo n.º 25
0
        public ActionResult ValueCreatePopup(string btnId, string formId, CheckoutAttributeValueModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                return(AccessDeniedView());
            }

            var checkoutAttribute = _checkoutAttributeService.GetCheckoutAttributeById(model.CheckoutAttributeId);

            if (checkoutAttribute == null)
            {
                //No checkout attribute found with the specified id
                return(RedirectToAction("List"));
            }

            model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
            model.BaseWeightIn             = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId).Name;

            if (ModelState.IsValid)
            {
                var cav = new CheckoutAttributeValue()
                {
                    CheckoutAttributeId = model.CheckoutAttributeId,
                    Name             = model.Name,
                    ColorSquaresRgb  = model.ColorSquaresRgb,
                    PriceAdjustment  = model.PriceAdjustment,
                    WeightAdjustment = model.WeightAdjustment,
                    IsPreSelected    = model.IsPreSelected,
                    DisplayOrder     = model.DisplayOrder
                };

                _checkoutAttributeService.InsertCheckoutAttributeValue(cav);
                UpdateValueLocales(cav, model);

                ViewBag.RefreshPage = true;
                ViewBag.btnId       = btnId;
                ViewBag.formId      = formId;
                return(View(model));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 26
0
        protected virtual List <LocalizedProperty> UpdateValueLocales(CheckoutAttributeValue checkoutAttributeValue, CheckoutAttributeValueModel model)
        {
            List <LocalizedProperty> localized = new List <LocalizedProperty>();

            foreach (var local in model.Locales)
            {
                if (!(String.IsNullOrEmpty(local.Name)))
                {
                    localized.Add(new LocalizedProperty()
                    {
                        LanguageId  = local.LanguageId,
                        LocaleKey   = "Name",
                        LocaleValue = local.Name,
                        _id         = ObjectId.GenerateNewId().ToString(),
                        Id          = localized.Count > 0 ? localized.Max(x => x.Id) + 1 : 1,
                    });
                }
            }
            return(localized);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Gets checkout attribute value price
        /// </summary>
        /// <param name="cav">Checkout attribute value</param>
        /// <param name="includingTax">A value indicating whether calculated price should include tax</param>
        /// <param name="customer">Customer</param>
        /// <param name="error">Error</param>
        /// <returns>Price</returns>
        public static decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav,
                                                        bool includingTax, Customer customer, ref string error)
        {
            if (cav == null)
            {
                throw new ArgumentNullException("cav");
            }

            decimal price = cav.PriceAdjustment;

            if (cav.CheckoutAttribute.IsTaxExempt)
            {
                return(price);
            }

            bool priceIncludesTax = TaxManager.PricesIncludeTax;
            int  taxClassId       = cav.CheckoutAttribute.TaxCategoryId;

            return(GetPrice(null, taxClassId, price, includingTax, customer, priceIncludesTax, ref error));
        }
Exemplo n.º 28
0
        /// <summary>
        /// Gets checkout attribute value price
        /// </summary>
        /// <param name="cav">Checkout attribute value</param>
        /// <param name="includingTax">A value indicating whether calculated price should include tax</param>
        /// <param name="customer">Customer</param>
        /// <param name="taxRate">Tax rate</param>
        /// <returns>Price</returns>
        public virtual decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav,
                                                         bool includingTax, Customer customer, out decimal taxRate)
        {
            if (cav == null)
            {
                throw new ArgumentNullException("cav");
            }

            taxRate = decimal.Zero;

            var priceIncludesTax = _taxSettings.PricesIncludeTax;
            var taxClassId       = cav.CheckoutAttribute.TaxCategoryId;
            var price            = cav.PriceAdjustment;

            if (cav.CheckoutAttribute.IsTaxExempt)
            {
                return(price);
            }

            return(GetProductPrice(null, taxClassId, price, includingTax, customer, _workContext.WorkingCurrency, priceIncludesTax, out taxRate));
        }
Exemplo n.º 29
0
        /// <summary>
        /// Gets checkout attribute value price
        /// </summary>
        /// <param name="cav">Checkout attribute value</param>
        /// <param name="includingTax">A value indicating whether calculated price should include tax</param>
        /// <param name="customer">Customer</param>
        /// <param name="taxRate">Tax rate</param>
        /// <returns>Price</returns>
        public virtual decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav,
                                                         bool includingTax, Customer customer, out decimal taxRate)
        {
            if (cav == null)
            {
                throw new ArgumentNullException("cav");
            }

            taxRate = decimal.Zero;

            decimal price = cav.PriceAdjustment;

            if (cav.CheckoutAttribute.IsTaxExempt)
            {
                return(price);
            }

            bool priceIncludesTax = _taxSettings.PricesIncludeTax;
            int  taxClassId       = cav.CheckoutAttribute.TaxCategoryId;

            return(GetArticlePrice(null, taxClassId, price, includingTax, customer,
                                   priceIncludesTax, out taxRate));
        }
Exemplo n.º 30
0
        /// <summary>
        /// Gets checkout attribute value price
        /// </summary>
        /// <param name="cav">Checkout attribute value</param>
        /// <param name="includingTax">A value indicating whether calculated price should include tax</param>
        /// <param name="customer">Customer</param>
        /// <param name="taxRate">Tax rate</param>
        /// <returns>Price</returns>
        public virtual decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav,
                                                         bool includingTax, Customer customer, out decimal taxRate)
        {
            if (cav == null)
            {
                throw new ArgumentNullException("cav");
            }

            taxRate = decimal.Zero;
            var     checkoutAttribute = EngineContext.Current.Resolve <ICheckoutAttributeService>().GetCheckoutAttributeById(cav.CheckoutAttributeId);
            decimal price             = cav.PriceAdjustment;

            if (checkoutAttribute.IsTaxExempt)
            {
                return(price);
            }

            bool   priceIncludesTax = _taxSettings.PricesIncludeTax;
            string taxClassId       = checkoutAttribute.TaxCategoryId;

            return(GetProductPrice(null, taxClassId, price, includingTax, customer,
                                   priceIncludesTax, out taxRate));
        }