question

adamd avatar image
adamd asked ·

Can you update an Order Type through the Order Connector?

So we trying to update the order type of an order through the clover sdk.

We can do this through the Rest Api by using the following api call.

https://apisandbox.dev.clover.com/v3/merchants/mid/orders/oId?expand=orderType

{

"orderType":{

"id":"oTId"

}

}

But we want to do this using the order connector. We have tried doing something similar to this.

OrderConnector mOrderConnector = new OrderConnector(context, AccountData.sAccount, null);
OrderType orderType = new OrderType();
orderType.setId(oTid);
mOrders.get(i).setOrderType(orderType);
mOrderConnector.updateOrder(mOrders.get(i));

mOrders being a a list of orders retrieved from the sdk.

We are not getting any error messages or exceptions being thrown. Can we actually do this via the order connector?

Orders
10 |2000 characters needed characters left characters exceeded

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

1 Answer

· Write an Answer
Nicholas Ho avatar image
Nicholas Ho answered ·

You can use the json object of the orderType from our REST API (/v3/merchants/mId/order_types/orderTypeId) and create an orderType object by passing it in as a string: https://clover.github.io/clover-android-sdk/com/clover/sdk/v3/order/OrderType.html#OrderType-java.lang.String-

Then use that to set the order type on your order with setOrderType the update it with the order connector.

Since order types can affect the tax on an order, you cannot update the order type on an order that is already locked.


// Set OrderType where orderId is a string of the order ID
// and json is a JSONObject created from a string of the JSON
Order order = mOrderConnector.getOrder(orderId);
OrderType orderType = new OrderType(json);
order.setOrderType(orderType);
mOrderConnector.updateOrder(order);



Share
10 |2000 characters needed characters left characters exceeded

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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