question

dhanaraj avatar image
dhanaraj asked aakashmcoderz commented

I am creating orders using orders v3 sdk. quanity not applied.

I am trying to add the multiple line items with multiple quantities.but item quantity not reflected in the code.

morder=OrderConnector.createOrder(new Order());

And Example like below,
mLineItem = orderConnector.addFixedPriceLineItem(mOrder.getId(), mItem.getId(), null, null);
mLineItem.setUnitQuantity(4).
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.

Raymond Lee avatar image
Raymond Lee Deactivated answered Raymond Lee Deactivated edited
The Unit Quantity is for PerUnitLineItems (for example, 1.25 lb of potatoes), where unitQuantity would be 1250, and the unitName would be "lb". See this answer for details.

In order to add multiple of a line item, you have to add it multiple times. So for your example, if you want to add that item 3 times:
for (int i = 0; i < 3; i++) {
	orderConnector.addFixedPriceLineItem(mOrder.getId(), mItem.getId(), null, null);
}

If you need to retrieve the created LineItem object, you can call your original line:
mLineItem = orderConnector.addFixedPriceLineItem(mOrder.getId(), mItem.getId(), null, null);

-Raymond
10 |2000

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

chanel avatar image
chanel Deactivated answered aakashmcoderz commented
To set the quantity of a line item, you'll need to use the following:

mLineItem.setUnitQty(4);
orderConnector.updateLineItems(mOrder.getId(), Arrays.asList(mLineItem));
3 comments
10 |2000

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

dhanaraj avatar image dhanaraj commented ·

@Chanel it throws com.clover.sdk.v1.ClientException: status code: 400 no valid line item updates found

0 Likes 0 ·
dhanaraj avatar image dhanaraj dhanaraj commented ·

@Chanel any updates regarding this issue.

0 Likes 0 ·
aakashmcoderz avatar image aakashmcoderz commented ·

I am also getting the same exception ::
com.clover.sdk.v1.ClientException: status code: 400
while trying to update using updateOrder()

0 Likes 0 ·
dhanaraj avatar image
dhanaraj answered
@Raymond Lee is there any posibble solution?
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