Calculate volume discount with api

Ali Heristchian asked on December 6, 2014 15:38

Hi,
How can I calculate total volume discount of special order item with API?
Thank you

Recent Answers


Sandro Jankovic answered on December 8, 2014 10:20

Hello,

The volume discount API example is available under ~\YourProjectFolder\CMSApiExamples\Code\Ecommerce, #region "API examples - Volume discount" on line 2978:

   private bool CreateVolumeDiscount()
    {
        // Get the data
        var product = SKUInfoProvider.GetSKUs()
                           .WhereStartsWith("SKUName", "MyNew")
                           .FirstOrDefault();

        if (product != null)
        {
            // Create new volume discount object
            VolumeDiscountInfo newDiscount = new VolumeDiscountInfo();

            // Set the properties
            newDiscount.VolumeDiscountMinCount = 100;
            newDiscount.VolumeDiscountValue = 20;
            newDiscount.VolumeDiscountSKUID = product.SKUID;
            newDiscount.VolumeDiscountIsFlatValue = false;

            // Create the volume discount
            VolumeDiscountInfoProvider.SetVolumeDiscountInfo(newDiscount);

            return true;
        }

Please let me know if you have any additional questions about this.

Best Regards,

Sandro

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.