Developer forum

Forum » Development » GetDiscountById and GetDiscounts methods

GetDiscountById and GetDiscounts methods

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

Are there any public methods to get a discount or a list/collection of discounts from the API?

 

I am building a new PromoCodeChecker that takes not only a voucher code, but also an Order and a DiscountId. Ultimately I'll check some conditions to determine why a discount may not have been applied to an order (it's a custom thing). The goal is not to capture all situations, but just to get the most basic ones that fit the customer needs and with time we can grow this more and more.

 

During this process I also noticed that the Discount class (Dynamicweb.Ecommerce.Orders.Discounts.Discount) does not have the Discount Id property, which I found very odd. Is that by design?

 

Best Regards,

Nuno Aguiar

 

 


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Dynamicweb.Ecommerce.Orders.Discounts.Discount.GetDiscounts() - see https://doc.dynamicweb.com/api/html/513d8e11-98e9-acbe-1152-bc9783991dfe.htm

It has an ID property (Inherited from its base class DBObject).

Do not care about the obsolete warnings in the docs. They have moved to DiscountService in 9.6 which is not public.

BR Nicolai

Votes for this answer: 1
 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Thanks, that works for me.

 

I am confused about the ID though. It's an int but discount Ids are strings like DISCOUNT1. Should I concatenate the string from EcomNumbers with the ID property?

 

Best Regards,

Nuno Aguiar

 
Nicolai Pedersen
Reply

It is an integer. See dump.

Discount id on the orderline is string, because the old discounts (SalesDiscounts) are using string ids.

NP

Capture.PNG
 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Ah... I see. Thanks for confirming.

 

You must be logged in to post in the forum