Skip to main content
Published: July 23 2010, 6:00:00 PMUpdated: November 28 2020, 8:29:43 PM

VB.NET AddFixedPriceItem sample for multi-variation listings for UK. This has been written using the .NET SDK v817. 

Multi-variation listings contain items that are logically the same product, but that vary in their manufacturing details or packaging.

 

Below is the code. Corresponding SOAP request is attached with this article.


'© 2010-2013 eBay Inc., All Rights Reserved
'Licensed under CDDL 1.0 - http://opensource.org/licenses/cddl1.php

Imports eBay.Service.Call
Imports eBay.Service.Core.Sdk
Imports eBay.Service.Util
Imports eBay.Service.Core.Soap

Namespace Trading_Samples
        Public Class AddFixedPriceItem
                'AddFPItem - multi-variation items
                Private Sub AddFPItemWithVariations()

                        'create the context
                        Dim context As New ApiContext()

                        'set the User token
                        context.ApiCredential.eBayToken = "Your token"

                        'set the server url
                        context.SoapApiServerUrl = "https://api.sandbox.ebay.com/wsapi"

                        'enable logging
                        context.ApiLogManager = New ApiLogManager()
                        context.ApiLogManager.ApiLoggerList.Add(New FileLogger("log.txt", True, True, True))
                        context.ApiLogManager.EnableLogging = True

                        'set the version
                        context.Version = "817"
                        context.Site = SiteCodeType.UK

                        'create the call object
                        Dim AddFPItemCall As New AddFixedPriceItemCall(context)

                        AddFPItemCall.AutoSetItemUUID = True

                        'create an item object and set the properties
                        Dim item As New ItemType()

                        'set the item condition depending on the value from GetCategoryFeatures
                        item.ConditionID = 1000
                        'new with tags
                        'Basic properties of a listing
                        item.Country = CountryCodeType.GB
                        item.Currency = CurrencyCodeType.GBP


                        'Track item by SKU
                        item.InventoryTrackingMethod = InventoryTrackingMethodCodeType.SKU
                        item.SKU = "VARPARENT"

                        item.Description = "test - do not bid or buy"
                        item.Title = "test - do not bid or buy"
                        item.SubTitle = "Test Item"
                        item.ListingDuration = "Days_7"

                        item.PaymentMethods = New BuyerPaymentMethodCodeTypeCollection()
                        item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal)
                        item.PayPalEmailAddress = "test@test.com"
                        item.PostalCode = "SE6 1AL"

                        'Specify Shipping Services
                        item.DispatchTimeMax = 3
                        item.ShippingDetails = New ShippingDetailsType()
                        item.ShippingDetails.ShippingServiceOptions = New ShippingServiceOptionsTypeCollection()

                        Dim shipservice1 As New ShippingServiceOptionsType()
                        shipservice1.ShippingService = "UK_SellersStandardRate"
                        shipservice1.ShippingServicePriority = 1
                        shipservice1.ShippingServiceCost = New AmountType()
                        shipservice1.ShippingServiceCost.currencyID = CurrencyCodeType.GBP
                        shipservice1.ShippingServiceCost.Value = 1.0

                        shipservice1.ShippingServiceAdditionalCost = New AmountType()
                        shipservice1.ShippingServiceAdditionalCost.currencyID = CurrencyCodeType.GBP
                        shipservice1.ShippingServiceAdditionalCost.Value = 1.0

                        item.ShippingDetails.ShippingServiceOptions.Add(shipservice1)

                        Dim shipservice2 As New ShippingServiceOptionsType()
                        shipservice2.ShippingService = "UK_RoyalMailFirstClassStandard"
                        shipservice2.ShippingServicePriority = 2
                        shipservice2.ShippingServiceCost = New AmountType()
                        shipservice2.ShippingServiceCost.currencyID = CurrencyCodeType.GBP
                        shipservice2.ShippingServiceCost.Value = 4.0

                        shipservice2.ShippingServiceAdditionalCost = New AmountType()
                        shipservice2.ShippingServiceAdditionalCost.currencyID = CurrencyCodeType.GBP
                        shipservice2.ShippingServiceAdditionalCost.Value = 1.0

                        item.ShippingDetails.ShippingServiceOptions.Add(shipservice2)

                        'Specify Return Policy
                        item.ReturnPolicy = New ReturnPolicyType()
                        item.ReturnPolicy.ReturnsAcceptedOption = "ReturnsAccepted"

                        item.PrimaryCategory = New CategoryType()
                        item.PrimaryCategory.CategoryID = "57991"

                        'Add Item Specifics
                        item.ItemSpecifics = New NameValueListTypeCollection()

                        Dim ItemSpecs As New NameValueListTypeCollection()

                        Dim nv1 As New NameValueListType()
                        Dim valueCol1 As New StringCollection()

                        nv1.Name = "Brand"
                        valueCol1.Add("Ralph Lauren")
                        nv1.Value = valueCol1
                        ItemSpecs.Add(nv1)

                        item.ItemSpecifics = ItemSpecs

                        'Specify VariationSpecificsSet
                        item.Variations = New VariationsType()

                        item.Variations.VariationSpecificsSet = New NameValueListTypeCollection()

                        Dim NVListVS1 As New NameValueListType()
                        NVListVS1.Name = "Collar Size"
                        Dim VSvaluecollection1 As New StringCollection()
                        Dim Size As [String]() = {"XS", "S", "M", "L", "XL"}
                        VSvaluecollection1.AddRange(Size)

                        NVListVS1.Value = VSvaluecollection1
                        item.Variations.VariationSpecificsSet.Add(NVListVS1)

                        Dim NVListVS2 As New NameValueListType()
                        NVListVS2.Name = "Colour"
                        Dim VSvaluecollection2 As New StringCollection()
                        Dim Colour As [String]() = {"Black", "Blue"}
                        VSvaluecollection2.AddRange(Colour)

                        NVListVS2.Value = VSvaluecollection2
                        item.Variations.VariationSpecificsSet.Add(NVListVS2)


                        'Specify Variations
                        Dim VarCol As New VariationTypeCollection()

                        'Variation 1 - Black S
                        Dim var1 As New VariationType()
                        var1.SKU = "VAR1"
                        var1.Quantity = 10
                        var1.StartPrice = New AmountType()
                        var1.StartPrice.currencyID = CurrencyCodeType.GBP
                        var1.StartPrice.Value = 35
                        var1.VariationSpecifics = New NameValueListTypeCollection()

                        Dim Var1Spec1 As New NameValueListType()
                        Dim Var1Spec1Valuecoll As New StringCollection()

                        Var1Spec1.Name = "Colour"
                        Var1Spec1Valuecoll.Add("Black")
                        Var1Spec1.Value = Var1Spec1Valuecoll

                        var1.VariationSpecifics.Add(Var1Spec1)

                        Dim Var1Spec2 As New NameValueListType()
                        Dim Var1Spec2Valuecoll As New StringCollection()

                        Var1Spec2.Name = "Collar Size"
                        Var1Spec2Valuecoll.Add("S")
                        Var1Spec2.Value = Var1Spec2Valuecoll

                        var1.VariationSpecifics.Add(Var1Spec2)

                        VarCol.Add(var1)

                        'Variation 2 - Black L
                        Dim var2 As New VariationType()
                        var2.SKU = "VAR2"
                        var2.Quantity = 10
                        var2.StartPrice = New AmountType()
                        var2.StartPrice.currencyID = CurrencyCodeType.GBP
                        var2.StartPrice.Value = 45

                        var2.VariationSpecifics = New NameValueListTypeCollection()

                        Dim Var2Spec1 As New NameValueListType()
                        Dim Var2Spec1Valuecoll As New StringCollection()

                        Var2Spec1.Name = "Colour"
                        Var2Spec1Valuecoll.Add("Black")
                        Var2Spec1.Value = Var2Spec1Valuecoll

                        var2.VariationSpecifics.Add(Var2Spec1)

                        Dim Var2Spec2 As New NameValueListType()
                        Dim Var2Spec2Valuecoll As New StringCollection()

                        Var2Spec2.Name = "Collar Size"
                        Var2Spec2Valuecoll.Add("L")
                        Var2Spec2.Value = Var2Spec2Valuecoll

                        var2.VariationSpecifics.Add(Var2Spec2)

                        VarCol.Add(var2)

                        'Variation 3 - Blue M
                        Dim var3 As New VariationType()
                        var3.SKU = "VAR3"
                        var3.Quantity = 10
                        var3.StartPrice = New AmountType()
                        var3.StartPrice.currencyID = CurrencyCodeType.GBP
                        var3.StartPrice.Value = 40

                        var3.VariationSpecifics = New NameValueListTypeCollection()

                        Dim Var3Spec1 As New NameValueListType()
                        Dim Var3Spec1Valuecoll As New StringCollection()

                        Var3Spec1.Name = "Colour"
                        Var3Spec1Valuecoll.Add("Blue")
                        Var3Spec1.Value = Var3Spec1Valuecoll

                        var3.VariationSpecifics.Add(Var3Spec1)

                        Dim Var3Spec2 As New NameValueListType()
                        Dim Var3Spec2Valuecoll As New StringCollection()

                        Var3Spec2.Name = "Collar Size"
                        Var3Spec2Valuecoll.Add("M")
                        Var3Spec2.Value = Var3Spec2Valuecoll

                        var3.VariationSpecifics.Add(Var3Spec2)

                        VarCol.Add(var3)

                        'Variation 4 - Blue L
                        Dim var4 As New VariationType()
                        var4.SKU = "VAR4"
                        var4.Quantity = 10
                        var4.StartPrice = New AmountType()
                        var4.StartPrice.currencyID = CurrencyCodeType.GBP
                        var4.StartPrice.Value = 45

                        var4.VariationSpecifics = New NameValueListTypeCollection()

                        Dim Var4Spec1 As New NameValueListType()
                        Dim Var4Spec1Valuecoll As New StringCollection()

                        Var4Spec1.Name = "Colour"
                        Var4Spec1Valuecoll.Add("Blue")
                        Var4Spec1.Value = Var4Spec1Valuecoll

                        var4.VariationSpecifics.Add(Var4Spec1)

                        Dim Var4Spec2 As New NameValueListType()
                        Dim Var4Spec2Valuecoll As New StringCollection()

                        Var4Spec2.Name = "Collar Size"
                        Var4Spec2Valuecoll.Add("L")
                        Var4Spec2.Value = Var4Spec2Valuecoll

                        var4.VariationSpecifics.Add(Var4Spec2)

                        VarCol.Add(var4)

                        'Add Variation Specific Pictures
                        item.Variations.Pictures = New PicturesTypeCollection()

                        Dim pic As New PicturesType()
                        pic.VariationSpecificName = "Colour"
                        pic.VariationSpecificPictureSet = New VariationSpecificPictureSetTypeCollection()

                        Dim VarPicSet1 As New VariationSpecificPictureSetType()
                        VarPicSet1.VariationSpecificValue = "Black"
                        Dim PicURLVarPicSet1 As New StringCollection()
                        PicURLVarPicSet1.Add("http://i12.ebayimg.com/03/i/04/8a/5f/a1_1_sbl.JPG")
                        VarPicSet1.PictureURL = PicURLVarPicSet1

                        pic.VariationSpecificPictureSet.Add(VarPicSet1)

                        Dim VarPicSet2 As New VariationSpecificPictureSetType()
                        VarPicSet2.VariationSpecificValue = "Blue"
                        Dim PicURLVarPicSet2 As New StringCollection()
                        PicURLVarPicSet2.Add("http://i2.sandbox.ebayimg.com/03/i/00/3f/c5/92_1.JPG?set_id=8800004005")
                        VarPicSet2.PictureURL = PicURLVarPicSet2

                        pic.VariationSpecificPictureSet.Add(VarPicSet2)

                        item.Variations.Pictures.Add(pic)

                        item.Variations.Variation = VarCol

                        'Add item level pictures
                        item.PictureDetails = New PictureDetailsType()
                        item.PictureDetails.PictureURL = New StringCollection()
                        item.PictureDetails.PictureURL.Add("http://i2.sandbox.ebayimg.com/03/i/00/3f/c5/92_1.JPG?set_id=8800004005")
                        item.PictureDetails.PhotoDisplay = PhotoDisplayCodeType.SuperSize
                        item.PictureDetails.PhotoDisplaySpecified = True


                        AddFPItemCall.Item = item

                        'set the item and make the call
                        AddFPItemCall.Execute()

                        Console.WriteLine(AddFPItemCall.ApiResponse.Ack + " " + AddFPItemCall.ApiResponse.ItemID)
                End Sub
        End Class

End Namespace

Attachments
How well did this answer your question?
Answers others found helpful