Developer forum

Forum » Development » GET /dwapi/ecommerce/carts?ByCustomerNumber=true doesn't work

GET /dwapi/ecommerce/carts?ByCustomerNumber=true doesn't work

Tor Leeberg

It seems like ByCustomerNumber on Carts doesn't work as intended. Whenever I call it, it doesn't add the OrderCustomerNumber clause to the select statement

exec sp_executesql N'
DECLARE @DefaultRate float;
SET @DefaultRate = IsNull((SELECT TOP 1 CurrencyRate FROM EcomCurrencies WHERE CurrencyIsDefault = 1), 100);
DECLARE @Time datetime; 
SET @Time = @p0;  
OrderedOrders AS (  
SELECT ROW_NUMBER() OVER(ORDER BY OrderDate DESC) AS RowNumber,  EcomOrders.OrderId, ShopName, EcomRecurringOrder.*  , AccessUser.AccessUserName AS OrderSecondaryUserName  FROM EcomOrders WITH (NOLOCK)  
LEFT JOIN EcomCurrencies ON EcomOrders.OrderCurrencyCode = EcomCurrencies.CurrencyCode AND EcomCurrencies.CurrencyLanguageID = @p1  
LEFT JOIN EcomOrderStates ON EcomOrders.OrderStateID = EcomOrderStates.OrderStateID  
LEFT JOIN EcomShops ON EcomOrders.OrderShopID = EcomShops.ShopID  
LEFT JOIN EcomRmas ON EcomOrders.OrderID = EcomRmas.RmaReplacementOrderId  
LEFT JOIN AccessUser ON EcomOrders.OrderSecondaryUserID = AccessUser.AccessUserID  
LEFT JOIN EcomRecurringOrder ON EcomOrders.OrderRecurringOrderId = EcomRecurringOrder.RecurringOrderID  
LEFT JOIN EcomTrackAndTrace ON EcomOrders.OrderTrackAndTraceId = EcomTrackAndTrace.TrackAndTraceId  
EcomOrders.OrderDeleted = 0  AND 
EcomOrders.OrderComplete = 0  AND 
(EcomOrders.OrderIsQuote = 0 OR EcomOrders.OrderComplete = 1)  AND 
EcomOrders.OrderIsLedgerEntry = @p2  AND 
EcomOrders.OrderCart = 1  AND 
(EcomOrders.OrderIsRecurringOrderTemplate = 0 or OrderIsRecurringOrderTemplate is NULL)  
OrdersCount as  ( SELECT COUNT(*) AS TotalOrdersCount FROM OrderedOrders  )  
SELECT * FROM OrdersCount, OrderedOrders WITH (NOLOCK)  
WHERE RowNumber BETWEEN @p3 AND @p4  ORDER BY RowNumber',N'@p0 datetime,@p1 nvarchar(5),@p2 int,@p3 int,@p4 int',@p0='2023-08-25 06:27:20.367',@p1=N'LANG1',@p2=0,@p3=101,@p4=200
It seems to be a problem with the logic in CartController and OrderRepository. The Customer clause is only added if CustomerId > 0 and if ByCustomerNumber is true, only CustomerNumber is set. 


Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
This post has been marked as an answer

Good find.

Bug #15142, pull request made:

Votes for this answer: 1
Tor Leeberg

Super! Any ETA for when this will be released?

Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt

Hi Tor

Bugfix #15142 regarding Headless: ByCustomerNumber now fixed in Dynamicweb version 9.15.13

You can get this version from the download section

Sorry for any inconvenience this may have caused

Kind Regards
Dynamicweb Care Support
Kristian Kirkholt


You must be logged in to post in the forum