示例#1
0
        public static LineItem ToShopifyModel(this StorefrontModel.Cart.LineItem lineItem, StorefrontModel.WorkContext workContext)
        {
            var shopifyModel = new LineItem();

            //shopifyModel.Product = lineItem.Product.ToShopifyModel();
            shopifyModel.Fulfillment = null; // TODO
            shopifyModel.Grams       = lineItem.Weight;
            shopifyModel.Id          = lineItem.Id;
            //shopifyModel.Image = lineItem.Product.PrimaryImage != null ? lineItem.Product.PrimaryImage.ToShopifyModel() : null;
            shopifyModel.LinePrice = lineItem.ExtendedPrice.Amount;
            shopifyModel.Price     = lineItem.PlacedPrice.Amount;
            shopifyModel.ProductId = lineItem.ProductId;
            //shopifyModel.Properties = null; // TODO
            shopifyModel.Quantity         = lineItem.Quantity;
            shopifyModel.RequiresShipping = lineItem.RequiredShipping;
            shopifyModel.Sku       = lineItem.Sku;
            shopifyModel.Taxable   = lineItem.TaxIncluded;
            shopifyModel.Title     = lineItem.Name;
            shopifyModel.Type      = null; // TODO
            shopifyModel.Url       = null; // TODO
            shopifyModel.Variant   = null; // TODO
            shopifyModel.VariantId = null; // TODO
            shopifyModel.Vendor    = null; // TODO

            return(shopifyModel);
        }
        public virtual LineItem ToLiquidLineItem(StorefrontModel.Cart.LineItem lineItem, StorefrontModel.Language language, IStorefrontUrlBuilder urlBuilder)
        {
            var factory = ServiceLocator.Current.GetInstance <ShopifyModelFactory>();
            var result  = factory.CreateLineItem();

            result.InjectFrom <StorefrontModel.Common.NullableAndEnumValueInjecter>(lineItem);

            //shopifyModel.Product = lineItem.Product.ToShopifyModel();
            result.Fulfillment = null; // TODO
            result.Grams       = lineItem.Weight ?? 0m;
            result.Image       = new Image
            {
                Alt       = lineItem.Name,
                Name      = lineItem.Name,
                ProductId = lineItem.ProductId,
                Src       = lineItem.ImageUrl
            };
            result.LinePrice        = lineItem.ExtendedPrice.Amount * 100;
            result.LinePriceWithTax = lineItem.ExtendedPriceWithTax.Amount * 100;
            result.Price            = lineItem.PlacedPrice.Amount * 100;
            result.PriceWithTax     = lineItem.PlacedPriceWithTax.Amount * 100;
            result.Title            = lineItem.Name;
            result.VariantId        = lineItem.ProductId;

            result.Properties = new MetafieldsCollection("properties", language, lineItem.DynamicProperties);

            return(result);
        }
示例#3
0
        public virtual LineItem ToLiquidLineItem(StorefrontModel.Cart.LineItem lineItem, StorefrontModel.Language language, IStorefrontUrlBuilder urlBuilder)
        {
            var result = new LineItem();

            result.Id               = lineItem.Id;
            result.Quantity         = lineItem.Quantity;
            result.RequiresShipping = lineItem.RequiredShipping;
            result.Quantity         = lineItem.Quantity;
            result.Sku              = lineItem.Sku;
            result.Title            = lineItem.Name;
            result.Type             = lineItem.ProductType;
            result.Url              = lineItem.ImageUrl;

            result.Fulfillment = null; // TODO
            result.Grams       = lineItem.Weight ?? 0m;
            result.Image       = new Image
            {
                Alt       = lineItem.Name,
                Name      = lineItem.Name,
                ProductId = lineItem.ProductId,
                Src       = lineItem.ImageUrl
            };
            result.LinePrice        = lineItem.ExtendedPrice.Amount * 100;
            result.LinePriceWithTax = lineItem.ExtendedPriceWithTax.Amount * 100;
            result.Price            = lineItem.PlacedPrice.Amount * 100;
            result.PriceWithTax     = lineItem.PlacedPriceWithTax.Amount * 100;
            result.Title            = lineItem.Name;
            result.VariantId        = lineItem.ProductId;

            result.Properties = new MetafieldsCollection("properties", language, lineItem.DynamicProperties);

            return(result);
        }
示例#4
0
        public static LineItem ToShopifyModel(this StorefrontModel.Cart.LineItem lineItem, StorefrontModel.Language language, IStorefrontUrlBuilder urlBuilder)
        {
            var converter = new ShopifyModelConverter();

            return(converter.ToLiquidLineItem(lineItem, language, urlBuilder));
        }
        public static LineItem ToShopifyModel(this StorefrontModel.Cart.LineItem lineItem, StorefrontModel.Language language, IStorefrontUrlBuilder urlBuilder)
        {
            var converter = ServiceLocator.Current.GetInstance <ShopifyModelConverter>();

            return(converter.ToLiquidLineItem(lineItem, language, urlBuilder));
        }