示例#1
0
        static public async Task PortItemsAsync(string locationId)
        {
            V1Fee tax = await CreateTaxV1(locationId);

            string discoutId = await CreateDiscount(locationId);

            List <ShopifySharp.Product> products = await Shopify.GetProductsAsync();

            V1ItemsApi v1 = new V1ItemsApi();

            foreach (ShopifySharp.Product prod in products)
            {
                System.Console.WriteLine(prod.Title);
                V1Item item = new V1Item(
                    Name: prod.Title,
                    Type: "NORMAL",
                    Visibility: "PUBLIC",
                    AvailableOnline: true,
                    Variations: new List <V1Variation>(),
                    Taxable: true,
                    Fees: new List <V1Fee>()
                {
                    tax
                }
                    );
                foreach (ShopifySharp.ProductVariant variant in prod.Variants)
                {
                    V1Variation vari = new V1Variation
                                       (
                        Name: variant.Title,
                        PricingType: "FIXEDPRICING",
                        PriceMoney: new V1Money(
                            Amount: variant.Price.HasValue ? ((int?)(variant.Price.Value * 100L)) : null,
                            CurrencyCode: "USD"
                            ),
                        TrackInventory: true,
                        UserData: variant.Id.ToString()
                                       );
                    item.Variations.Add(vari);
                }
                V1Item item2 = await v1.CreateItemAsync(locationId, item);

                ShopifySharp.ProductImage image = prod.Images.FirstOrDefault();
                if (image != null)
                {
                    await ImageUploader.PortImage(locationId, item2.Id, prod.Images.First().Src);
                }
            }
//			await SetInventory(products);
            await FixBarCodes(products);
            await FixLocations();
        }
示例#2
0
        static public async Task <V1Fee> CreateTaxV1(string locationId)
        {
            V1ItemsApi v1    = new V1ItemsApi();
            V1Fee      v1Fee = new V1Fee(
                null,
                "Sales Tax",
                ".089",
                "FEESUBTOTALPHASE",
                "TAX",
                true,
                true,
                "ADDITIVE",
                "USSALESTAX");
            V1Fee resp = await v1.CreateFeeAsync(locationId, v1Fee);

            return(resp);
        }