Order Items API returning error when order has both shipping and non-shipping items

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
gwalliman
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Tue Feb 20, 2018 5:32 pm

Order Items API returning error when order has both shipping and non-shipping items

Post by gwalliman » Mon Jul 22, 2019 12:23 pm

We noticed this behavior when trying to call the /api/Orders/Items endpoint. This endpoint works fine when the order has only items that can be shipped (physical products, etc.) but when the order has both shipping and non-shipping items (example: a book and a membership subscription) we get a 500 error with the message "An error has occurred."

How can we fix this? Thanks much!

User avatar
Shopping Cart Admin
AbleCommerce Admin
AbleCommerce Admin
Posts: 3055
Joined: Mon Dec 01, 2003 8:41 pm
Location: Vancouver, WA
Contact:

Re: Order Items API returning error when order has both shipping and non-shipping items

Post by Shopping Cart Admin » Thu Aug 08, 2019 11:23 am

Hello,

Please try this again and then go to the error log, so you can post the real error message.
Thanks for your support

Shopping Cart Guru
AbleCommerce.com
Follow us on Facebook

gwalliman
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Tue Feb 20, 2018 5:32 pm

Re: Order Items API returning error when order has both shipping and non-shipping items

Post by gwalliman » Thu Aug 08, 2019 3:36 pm

Hello, thanks much for the response!

I'm assuming you mean the error log within the web UI at /Admin/Help/ErrorLog.aspx? This log does not seem to display any errors thrown by the API failure. Is there another error log (perhaps an on-server log) that might show these errors?

gwalliman
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Tue Feb 20, 2018 5:32 pm

Re: Order Items API returning error when order has both shipping and non-shipping items

Post by gwalliman » Sun Aug 25, 2019 1:17 pm

It's been over two weeks - could I please get a response?

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: Order Items API returning error when order has both shipping and non-shipping items

Post by nadeem » Mon Aug 26, 2019 1:52 pm

Hello,

You need to check the log file inside App_Data i.e. Website/App_Data/app.log file to find the actual error. I just reviewed the API code that is originating the error has a null reference exception. You can fix the error if you have CommerceBuilder.WebApi source code.

Open the Controllers/OrdersControllers.cs file, locate the following line of code:

Code: Select all

OrderShipmentId = item.OrderShipment.Id,
and replace with

Code: Select all

OrderShipmentId = item.OrderShipment == null ? 0 : item.OrderShipment.Id,
There are two locations that need the above update in the same controller, one is under GetItemsByOrderId(int id) action method and the other is under GetItemsByOrderNumber(int orderNumber)
After making the above change, compile the CommerceBuilder.WebApi project and then compile the website to reflect this update.

Post Reply