question

steve avatar image
steve asked Jacob Abrams answered

How to update an order using OrderConnector

Hi,

I have the following code that returns a valid Order:

Order order = mOrderConnector.getOrder(orderId);

One LineItem has a discount and I'm trying to change the name of the discount. I can get a reference to the Discount in question and when I call setName() on the Discount object the JSON string associated with the order above gets updated in memory as expected. However when I call: order = mOrderConnector.updateOrder(order); the JSON string in the order variable that is returned goes back to what it was before I updated the discount name.

Does the updateOrder() method update the local database (content provider) or is there another method call I need to make so the Order object reflects the changes that I made?

Thanks,

Steve

Orders
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jacob Abrams avatar image
Jacob Abrams answered

Typically if you are trying to change something that is nested in an object you will you need to use a specific method in the connector to do that. It may also be there are certain things that cannot be changed after the fact. You may need to delete the line item discount and create a new one with the new name you want. Try using deleteLineItemDiscounts and addLineItemDiscount or addLineItemDiscount2 (I see they do the same thing but return different object types).

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

steve avatar image
steve answered

Thanks jacobabrams,

I went down the route of deleting and recreating the discount in the LineItem to solve the problem.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community