Developer forum

Forum » Development » Orderline TotalDiscount not set on initial POST request when adding product through dwapi

Orderline TotalDiscount not set on initial POST request when adding product through dwapi

Mikkel Hammer
Mikkel Hammer
Reply

Hi DW,

When adding a product with a product discount through the dwapi endpoint, /dwapi/ecommerce/carts/{secret}/items/, the orderline TotalDiscount is not set on the initial POST request, and requires another request that manipulates the cart, either another product added or a patch request.

Reproduce step:
/dwapi/ecommerce/carts?CurrencyCode=DKK&CountryCode=DK&LanguageId=LANG1&ShopId=SHOP1
/dwapi/ecommerce/carts/{secret]/items/ with body (this product has aproduct discount)

{

    "ProductId""DAA003",
    "ProductVariantId""SP16961",
    "Quantity"1
}


Here is the orderlines added for the first request:

{
            "Id""OL292838",
            "ProductId""DAA003",
            "ProductVariantId""SP16961",
            "ProductLanguageId""LANG1",
            "ProductName""TRANSDUCER HOLDER",
            "ProductNumber""71011",
            "ProductVariantName""TRANSDUCER HOLDER / ONE SIZE",
            "ProductImage""/Files/Images/PIM_IMG_png_72_dpi_1000x1000/photo-coming.Png",
            "PrimaryOrDefaultGroup": {
                "Id""SPSHOP12-24",
                "Name""Other"
            },
            "Quantity"1.0,
            "UnitName""",
            "OrderLineFields": {},
            "Price": {
                "Price"19.53,
                "PriceFormatted""kr. 19,53",
                "PriceWithoutVat"19.53,
                "PriceWithoutVatFormatted""kr. 19,53",
                "PriceWithVat"24.0219,
                "PriceWithVatFormatted""kr. 24,02",
                "Vat"4.4919,
                "VatFormatted""kr. 4,49",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "UnitPrice": {
                "Price"19.53,
                "PriceFormatted""kr. 19,53",
                "PriceWithoutVat"19.53,
                "PriceWithoutVatFormatted""kr. 19,53",
                "PriceWithVat"24.0219,
                "PriceWithVatFormatted""kr. 24,02",
                "Vat"4.4919,
                "VatFormatted""kr. 4,49",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "UnitPriceBeforeDiscount": {
                "PriceFormatted""kr. 0,00",
                "PriceWithoutVatFormatted""kr. 0,00",
                "PriceWithVatFormatted""kr. 0,00",
                "VatFormatted""kr. 0,00",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "TotalDiscount": {
                "PriceFormatted""kr. 0,00",
                "PriceWithoutVatFormatted""kr. 0,00",
                "PriceWithVatFormatted""kr. 0,00",
                "VatFormatted""kr. 0,00",
                "VATPercentFormatted""0%",
                "CurrencyCode""EUR"
            }
        },
        {
            "Id""OL292839",
            "ProductLanguageId""",
            "ProductName""20% outlet discount",
            "ProductImage""/Files/Images/PIM_IMG_png_72_dpi_1000x1000/photo-coming.Png",
            "PrimaryOrDefaultGroup": {},
            "Quantity"1.0,
            "UnitName""",
            "OrderLineType""ProductDiscount",
            "OrderLineFields": {},
            "Price": {
                "Price"-3.907953,
                "PriceFormatted""kr. -3,91",
                "PriceWithoutVat"-3.907953,
                "PriceWithoutVatFormatted""kr. -3,91",
                "PriceWithVat"-4.80678219,
                "PriceWithVatFormatted""kr. -4,81",
                "Vat"-0.89882918999999994,
                "VatFormatted""kr. -0,90",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "UnitPrice": {
                "Price"-3.907953,
                "PriceFormatted""kr. -3,91",
                "PriceWithoutVat"-3.907953,
                "PriceWithoutVatFormatted""kr. -3,91",
                "PriceWithVat"-4.80678219,
                "PriceWithVatFormatted""kr. -4,81",
                "Vat"-0.89882918999999994,
                "VatFormatted""kr. -0,90",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "UnitPriceBeforeDiscount": {
                "PriceFormatted""kr. 0,00",
                "PriceWithoutVatFormatted""kr. 0,00",
                "PriceWithVatFormatted""kr. 0,00",
                "VatFormatted""kr. 0,00",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "TotalDiscount": {
                "PriceFormatted""kr. 0,00",
                "PriceWithoutVatFormatted""kr. 0,00",
                "PriceWithVatFormatted""kr. 0,00",
                "VatFormatted""kr. 0,00",
                "VATPercentFormatted""0%",
                "CurrencyCode""EUR"
            }
        }

We then need to add another product or patch, here we just do a /dwapi/ecommerce/carts/{secret} with body

{
    "DisplayName""Test name"
}

and now the orderlines returned is, where the productorderline has the correct TotalDiscount:

{
            "Id""OL292838",
            "ProductId""DAA003",
            "ProductVariantId""SP16961",
            "ProductLanguageId""LANG1",
            "ProductName""TRANSDUCER HOLDER",
            "ProductNumber""71011",
            "ProductVariantName""TRANSDUCER HOLDER / ONE SIZE",
            "ProductImage""/Files/Images/PIM_IMG_png_72_dpi_1000x1000/photo-coming.Png",
            "PrimaryOrDefaultGroup": {
                "Id""SPSHOP12-24",
                "Name""Other"
            },
            "Quantity"1.0,
            "UnitName""",
            "OrderLineFields": {},
            "Price": {
                "Price"19.53,
                "PriceFormatted""kr. 19,53",
                "PriceWithoutVat"19.53,
                "PriceWithoutVatFormatted""kr. 19,53",
                "PriceWithVat"24.0219,
                "PriceWithVatFormatted""kr. 24,02",
                "Vat"4.4919,
                "VatFormatted""kr. 4,49",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "UnitPrice": {
                "Price"19.53,
                "PriceFormatted""kr. 19,53",
                "PriceWithoutVat"19.53,
                "PriceWithoutVatFormatted""kr. 19,53",
                "PriceWithVat"24.0219,
                "PriceWithVatFormatted""kr. 24,02",
                "Vat"4.4919,
                "VatFormatted""kr. 4,49",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "UnitPriceBeforeDiscount": {
                "PriceFormatted""kr. 0,00",
                "PriceWithoutVatFormatted""kr. 0,00",
                "PriceWithVatFormatted""kr. 0,00",
                "VatFormatted""kr. 0,00",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "TotalDiscount": {
                "Price"-3.907953,
                "PriceFormatted""kr. -3,91",
                "PriceWithoutVat"-3.907953,
                "PriceWithoutVatFormatted""kr. -3,91",
                "PriceWithVat"-4.80678219,
                "PriceWithVatFormatted""kr. -4,81",
                "Vat"-0.89882918999999994,
                "VatFormatted""kr. -0,90",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            }
        },
        {
            "Id""OL292841",
            "ProductLanguageId""",
            "ProductName""20% outlet discount",
            "ProductImage""/Files/Images/PIM_IMG_png_72_dpi_1000x1000/photo-coming.Png",
            "PrimaryOrDefaultGroup": {},
            "Quantity"1.0,
            "UnitName""",
            "OrderLineType""ProductDiscount",
            "OrderLineFields": {},
            "Price": {
                "Price"-3.907953,
                "PriceFormatted""kr. -3,91",
                "PriceWithoutVat"-3.907953,
                "PriceWithoutVatFormatted""kr. -3,91",
                "PriceWithVat"-4.80678219,
                "PriceWithVatFormatted""kr. -4,81",
                "Vat"-0.89882918999999994,
                "VatFormatted""kr. -0,90",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "UnitPrice": {
                "Price"-3.907953,
                "PriceFormatted""kr. -3,91",
                "PriceWithoutVat"-3.907953,
                "PriceWithoutVatFormatted""kr. -3,91",
                "PriceWithVat"-4.80678219,
                "PriceWithVatFormatted""kr. -4,81",
                "Vat"-0.89882918999999994,
                "VatFormatted""kr. -0,90",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "UnitPriceBeforeDiscount": {
                "PriceFormatted""kr. 0,00",
                "PriceWithoutVatFormatted""kr. 0,00",
                "PriceWithVatFormatted""kr. 0,00",
                "VatFormatted""kr. 0,00",
                "VATPercent"23.0,
                "VATPercentFormatted""23%",
                "CurrencyCode""EUR"
            },
            "TotalDiscount": {
                "PriceFormatted""kr. 0,00",
                "PriceWithoutVatFormatted""kr. 0,00",
                "PriceWithVatFormatted""kr. 0,00",
                "VatFormatted""kr. 0,00",
                "VATPercentFormatted""0%",
                "CurrencyCode""EUR"
            }
        }



The discount is setup as a Product discount with a 20.01 %, the rest of the settings are default when creating a new discount.
The discount is not setup on the shop, but just under Product discount

 


We're on a DW 9.13.3 and Dynamicweb.Ecommerce 1.3.27 if it helps

EDIT: just as a note aswell, the Price, UnitPrice and UnitPriceBeforeDiscount is returned without any information about the 20% discount aswell. But getting the TotalDiscount on the inital POST would make it possible to make the calculation of prices yourself, if it's a bigger change to solve that aswell :)


Best regards,
Mikkel


Replies

 
Mikkel Hammer
Mikkel Hammer
Reply

Hi DW,

Any news on this? :)

Best regards,
Mikkel

 
Nicolai Pedersen
Reply

Hi Mikkel

I will send this to QA for verification. Sorry about the delay.

BR Nicolai

 
Mikkel Hammer
Mikkel Hammer
Reply

Hi Nicolai,

Thanks for the update!

Best regards,
Mikkel

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply
This post has been marked as an answer

Hi,

I was able to reproduce the issue with TotalDiscount on last DW9.13.4 as well. New task 7349 has been submitted to fix the bug. Thanks.

BR, Oleg QA

Votes for this answer: 1

 

You must be logged in to post in the forum