Esempio n. 1
0
        public void GetVariantOptionCategories_ReturnCategories()
        {
            var categories = variantRepository.GetVariantOptionCategories(skuWithVariants.SKUID);

            var colorCategory = categories.First(c => c.DisplayName.EqualsCSafe(categoryColor.CategoryDisplayName));

            CMSAssert.All(
                () => Assert.AreEqual(2, categories.Count(), "Variant option categories are not returned."),
                () => Assert.AreEqual(COLORS.Count(), colorCategory.CategoryOptions.Count(), "Category has wrong option count.")
                );
        }
Esempio n. 2
0
        private IEnumerable <ProductOptionCategoryViewModel> PrepareProductOptionCategoryViewModels(SKUInfo sku, Variant cheapestVariant)
        {
            var categories = mVariantRepository.GetVariantOptionCategories(sku.SKUID);

            // Set the selected options in the variant categories which represents the cheapest variant
            var variantCategories =
                cheapestVariant?.ProductAttributes.Select(
                    option =>
                    new ProductOptionCategoryViewModel(option.SKUID,
                                                       categories.FirstOrDefault(c => c.ID == option.SKUOptionCategoryID)));

            return(variantCategories);
        }
Esempio n. 3
0
        //EndDocSection:DifferentShippingAddress

        private object DummyEcommerceMethod()
        {
            IPricingService    pricingService     = null;
            ShoppingCart       shoppingCart       = null;
            SKUInfo            productSku         = null;
            Variant            variant            = null;
            IVariantRepository mVariantRepository = null;
            SKUTreeNode        product            = null;
            SKUInfo            sku   = null;
            DummyViewModel     model = null;
            Order             order  = null;
            PaymentResultInfo result = null;

            //DocSection:CalculatePriceOptions
            ProductPrice productPrice = pricingService.CalculatePrice(productSku, shoppingCart);
            //EndDocSection:CalculatePriceOptions

            //DocSection:FormatPriceOptions
            decimal price          = 5.50M;
            string  formattedPrice = shoppingCart.Currency.FormatPrice(price);
            //EndDocSection:FormatPriceOptions

            //DocSection:VariantDisplayImg
            var response = new
            {
                // ...

                imagePath = Url.Content(variant.ImagePath)
            };
            //EndDocSection:VariantDisplayImg

            //DocSection:DisplayAttributeSelection
            // Gets the cheapest variant from the product
            List <Variant> variants        = mVariantRepository.GetByProductId(product.NodeSKUID).OrderBy(v => v.VariantPrice).ToList();
            Variant        cheapestVariant = variants.FirstOrDefault();

            // Gets the product's option categories.
            IEnumerable <ProductOptionCategory> categories = mVariantRepository.GetVariantOptionCategories(sku.SKUID);

            // Gets the cheapest variant's selected attributes
            IEnumerable <ProductOptionCategoryViewModel> variantCategories = cheapestVariant?.ProductAttributes.Select(
                option =>
                new ProductOptionCategoryViewModel(option.SKUID,
                                                   categories.FirstOrDefault(c => c.ID == option.SKUOptionCategoryID)));

            //EndDocSection:DisplayAttributeSelection

            //DocSection:ShippingIsDifferent
            if (model.ShippingAddressIsDifferent)
            {
                // ...
            }
            //EndDocSection:ShippingIsDifferent

            //DocSection:DifferentPaymentMethods
            if (shoppingCart.PaymentMethod.PaymentOptionName.Equals("PaymentMethodCodeName"))
            {
                return(RedirectToAction("ActionForPayment", "MyPaymentGateway"));
            }
            //EndDocSection:DifferentPaymentMethods

            //DocSection:SetPaymentResult
            order.SetPaymentResult(result);
            //EndDocSection:SetPaymentResult

            //DocSection:RedirectForManualPayment
            return(RedirectToAction("ThankYou", new { orderID = order.OrderID }));
            //EndDocSection:RedirectForManualPayment
        }