Skip to main content
Published: April 25 2007, 11:37:00 AMUpdated: November 28 2020, 3:38:23 PM

SetShippingDiscountProfiles sample in C# using the SOAP API

SetShippingDiscountProfiles sample implemented in C# using Visual Studio .NET (original version, not 2003 or 2005) using the SOAP API

Summary

SetShippingDiscountProfiles sample implemented in C# using Visual Studio .NET (original version, not 2003 or 2005) using the SOAP API


Detailed Description

The attached command line sample project contains an implementation of the SetShippingDiscountProfiles API call.
This sample is intended to add a calculated shipping discount profile for the very first time.
For a user that has existing profiles and discount settings, some of the code will need slight adjustments.
The readme.txt file has a few simple notes about the project so please look at it when using the sample project.

Here is the main code snippet showing the actual use of this call contained in the attached sample project:

  // the CurrencyID associated with these profiles
  Request.CurrencyIDSpecified = true;
  Request.CurrencyID = CurrencyCodeType.USD;
  // the number of days a buyer has to combine purchases
  Request.CombinedDurationSpecified = true;
  Request.CombinedDuration = CombinedPaymentPeriodCodeType.Days_14;
  // we will be adding a rule for calculated shipping
  Request.ModifyActionCodeSpecified = true;
  Request.ModifyActionCode = ModifyActionCodeType.Add;
  // specify a rule for calculating the weight on your combined packages
  CalculatedShippingDiscountType calcShippingDiscount = new CalculatedShippingDiscountType();
  // specify "Combine all item weights"
  calcShippingDiscount.DiscountNameSpecified = true;
  calcShippingDiscount.DiscountName = DiscountNameCodeType.CombinedItemWeight;
  // 1 discount profile for calculated shipping
  DiscountProfileType calcDiscountProfile = new DiscountProfileType();
  // if we wanted to subtract some weight in this profile
  // the next 5 lines would be uncommented and
  // DiscountName above set to DiscountNameCodeType.WeightOff
  //calcDiscountProfile.WeightOff = new MeasureType();
  //calcDiscountProfile.WeightOff.measurementSystemSpecified = true;
  //calcDiscountProfile.WeightOff.measurementSystem = MeasurementSystemCodeType.English;
  //calcDiscountProfile.WeightOff.unit = "oz";
  //calcDiscountProfile.WeightOff.Value = 6;
  calcShippingDiscount.DiscountProfile = new DiscountProfileType[] {calcDiscountProfile};
  // set the CalculatedHandlingDiscount as
  // fixed shipping cost to charge for an order, regardless of the number of items in the order
  CalculatedHandlingDiscountType calcHandlingDiscount = new CalculatedHandlingDiscountType();
  calcHandlingDiscount.DiscountNameSpecified = true;
  calcHandlingDiscount.DiscountName = HandlingNameCodeType.CombinedHandlingFee;
  calcHandlingDiscount.OrderHandlingAmount = new AmountType();
  calcHandlingDiscount.OrderHandlingAmount.currencyID = CurrencyCodeType.USD;
  calcHandlingDiscount.OrderHandlingAmount.Value = 5;
  Request.CalculatedShippingDiscount = calcShippingDiscount;
  Request.CalculatedHandlingDiscount = calcHandlingDiscount;
  // no domestic insurance offered
  Request.ShippingInsurance = new ShippingInsuranceType();
  Request.ShippingInsurance.InsuranceOptionSpecified = true;
  Request.ShippingInsurance.InsuranceOption = InsuranceOptionCodeType.NotOffered;
  // no international insurance offered
  Request.InternationalShippingInsurance = new ShippingInsuranceType();
  Request.InternationalShippingInsurance.InsuranceOptionSpecified = true;
  Request.InternationalShippingInsurance.InsuranceOption = InsuranceOptionCodeType.NotOffered;
  // create a response object for this call
  SetShippingDiscountProfilesResponseType Response = new SetShippingDiscountProfilesResponseType();
  // we are now ready to make the call
  try
  {
       Response = svc.SetShippingDiscountProfiles(Request);
  ...

  }

Version Info

The attached project is based on the following versions:

SOAP API version 509
Visual Studio Original .NET (not 2003 or 2005)



Additional Resources

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