Find the answer to your question
Advanced Search
Sample code in C# to list an Item with mixed shipping types using .NET SDK
Summary
eBay supports a mix of flat and calculated shipping types on domestic and international shipping services. The seller can opt to use flat shipping for domestic shipping services and calculated shipping for international shipping services, and vice versa by setting the ShippingType to FlatDomesticCalculatedInternational and CalculatedDomesticFlatInternational respectively.
Detailed Description
Here is a sample C# code using .NET SDK to list an item with Shipping Services Flat Domestic and Calculated International shipping type:
/* © 2007-2014 eBay Inc., All Rights Reserved Licensed under CDDL 1.0 - http://opensource.org/licenses/cddl1.php */ using System; using eBay.Service.Call; using eBay.Service.Core.Sdk; using eBay.Service.Util; using eBay.Service.Core.Soap; namespace SDK3Examples public class AddItem } { public string AddItem(string UUID)
{ AddItemCall addItem = new AddItemCall(GetContext()); ItemType item = new ItemType(); item.Currency = CurrencyCodeType.USD; item.Country = CountryCodeType.US; item.Title = 'title'; item.Quantity = 1; item.PostalCode = '95125'; item.ListingDuration = 'Days_7'; item.PrimaryCategory = new CategoryType(); item.PrimaryCategory.CategoryID = '146301'; item.StartPrice = new AmountType(); item.StartPrice.currencyID = CurrencyCodeType.USD; item.StartPrice.Value = 20; item.UUID = UUID; item.ShippingDetails = new ShippingDetailsType(); // Flat Domestic Calculated International Shipping Type item.ShippingDetails.ShippingType = ShippingTypeCodeType.FlatDomesticCalculatedInternational; // Domestic Shipping Services item.ShippingDetails.ShippingServiceOptions = new ShippingServiceOptionsTypeCollection(); ShippingServiceOptionsType[] opt = new ShippingServiceOptionsType[1]; opt[0] = new ShippingServiceOptionsType(); opt[0].ShippingServiceCost = new AmountType(); opt[0].ShippingServiceCost.currencyID = CurrencyCodeType.USD; opt[0].ShippingServiceCost.Value = 5; opt[0].ShippingService = 'USPSPriority'; opt[0].ShippingServicePriority = 1; item.ShippingDetails.ShippingServiceOptions.Add(opt[0]); // Calculated Shipping values CalculatedShippingRateType calRate = new CalculatedShippingRateType(); calRate.OriginatingPostalCode = '95125'; calRate.ShippingPackage = ShippingPackageCodeType.PackageThickEnvelope; calRate.WeightMajor = new MeasureType(); calRate.WeightMajor.unit = 'lbs'; calRate.WeightMajor.Value = 2; calRate.WeightMinor = new MeasureType(); calRate.WeightMinor.unit = 'oz'; calRate.WeightMinor.Value = 6; item.ShippingDetails.CalculatedShippingRate = calRate; // International Shipping Services item.ShippingDetails.InternationalShippingServiceOption = new InternationalShippingServiceOptionsTypeCollection(); InternationalShippingServiceOptionsType[] Iopt = new InternationalShippingServiceOptionsType[1]; Iopt[0] = new InternationalShippingServiceOptionsType(); Iopt[0].ShippingService = 'USPSGlobalExpress'; Iopt[0].ShippingServicePriority = 1; item.ShippingDetails.InternationalShippingServiceOption.Add(Iopt[0]); Iopt[0].ShipToLocation = new StringCollection(); Iopt[0].ShipToLocation.Add('Worldwide'); FeeTypeCollection fees = addItem.AddItem(item); return item.ItemID; } public ApiContext GetContext() // Credentials for the call }
context.ApiCredential.eBayToken = 'token'; // Set the URL // Set logging // Set the version return context; } |
To flip this and set the domestic shipping type to calculated and international to flat:
1. set item.ShippingDetails.ShippingType = ShippingTypeCodeType.FlatDomesticCalculatedInternational
2. Remove the ShippingServiceCost for the domestic shipping services:
opt[0].ShippingServiceCost = new AmountType();
opt[0].ShippingServiceCost.currencyID = CurrencyCodeType.USD;
opt[0].ShippingServiceCost.Value = 5;
3. Add the ShippingServiceCost for the international shipping services:
Iopt[0].ShippingServiceCost = new AmountType();
Iopt[0].ShippingServiceCost.currencyID = CurrencyCodeType.USD;
Iopt[0].ShippingServiceCost.Value = 5;