Пример #1
0
        private void PriceForSelections(Catalog.Product p, OptionSelectionList selections)
        {
            this.IsValid = true;
            this.VariantId = string.Empty;
            this._ModifierAdjustments = 0;

            if (selections == null) return;
            if (p == null) return;

            // Check for Option Price Modifiers
            if (!p.HasOptions()) return;
            this._ModifierAdjustments = selections.GetPriceAdjustmentForSelections(p.Options);
            this.BasePrice += this._ModifierAdjustments;

            // Check for Variant Changes
            if (!p.HasVariants()) return;
            Variant v = p.Variants.FindBySelectionData(selections, p.Options);
            if (v == null)
            {
                this.IsValid = false;
                return;
            }

            // Assign Variant Attributes to this price data
            this.VariantId = v.Bvin;
            if (v.Sku.Trim().Length > 0) this.Sku = v.Sku;
            if (v.Price >= 0) this.BasePrice = v.Price + this._ModifierAdjustments;

        }