Developer forum

Forum » Ecommerce - Standard features » Getting discounts on product does not seem to work when using API

Getting discounts on product does not seem to work when using API

Hans Kloppenborg
Reply

Hello,

We are trying to retrieve the discounted price of a product using the API in our backend code, but get no discount, whatever method we use. The loopitem in the template works fine though.

Methods we tried on our retrieved product variable:

  1. product.Discounts() gives an empty collection (this is officially obsolete, but should still work)
  2. product.GetDiscounts(currencyCode, countryCode) gives an empty collection
  3. Dynamicweb.Ecommerce.Orders.SalesDiscounts.SalesDiscount.GetSalesDiscounts(pc, Dynamicweb.Ecommerce.International.Language.GetLanguage("LANG1")) where pc is a productcollection with just our product gives an empty collection
  4. Dynamicweb.Ecommerce.Orders.SalesDiscounts.SalesDiscount.GetSalesDiscounts(Dynamicweb.Ecommerce.International.Language.GetLanguage("LANG1")) gives a collection with 4 salesdiscount records, sadly the ValueProducts parameter of all those discounts is allways an empty collection.

Our discount is configured with the following parameters

<?xml version="1.0" encoding="utf-8"?><Parameters addin="Dynamicweb.Ecommerce.Orders.SalesDiscounts.ProductDiscount">
<Parameter addin="Dynamicweb.Ecommerce.Orders.SalesDiscounts.ProductDiscount" name="Products" value="[some][p:PROD3,]" />
</Parameters>

We would like to hear if we are doing something wrong, or if this is a bug.

Greets Hans


Replies

 
Nicolai Pedersen
Reply

Discounts are not available easily outside the frontend pipeline.

To calculate the discount we need to know the user, currency and other stuff that impacts the discount. Also all discounts that are not product discounts, cannot be calculaed without an order.

Unfortunately I have no quick fix for this - it requires a good look at the code to give you something.

You are using salesdiscounts - using the discount matrix would make it easier to get the discount. Would that be an option?

BR Nicolai

 

You must be logged in to post in the forum