question

lidongdong559 avatar image
lidongdong559 asked lidongdong559 commented

the UnitQuantity of LineItem is set to null for unknown reason.

I am creating some mock lineitems to the mock order object.

                    lineItem = new LineItem();
                    lineItem.setName(pItem.getTitle());
                    lineItem.setPrice((long) (pItem.getPrice() * 100));
                    lineItem.setUnitQty(pItem.getQuantity());

Log.d("demo1","quantity is "+lineItem.getUnitQty()); // get the correct amount

                    orderConnector.addCustomLineItem(order.getId(), lineItem, false);

Log.d("demo1", "quantity is " + lineItem.getUnitQty()); // get a null

         As soon as I save the lineitem into order with orderConnector then the unit quantity seems to vanish. Could someone help me?
        Thank you!
10 |2000

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

1 Answer

annie avatar image
annie answered lidongdong559 commented

Hi, unitQuantity is meant to be used with per-unit priced items (e.g. Fabric at $1.00/yd). So if you create a Fabric line item that's 5 yd @ $1.00/yd, 5 would be the unitQty (and "yd" would be the unitName). These will only be set if you add an lineitem based on a per-unit item.

Regarding the quantity I think you're expecting, see https://docs.clover.com/build/web-app... for more information:

Each lineItem represents a single Inventory item being purchased, a single portion of a variable price item, or an individual custom-item/manual-transaction amount.

If you would like multiple instances of a line item, add the line item to the order multiple times.

1 comment
10 |2000

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

lidongdong559 avatar image lidongdong559 commented ·

Thank you so much! I solved the problem by adding same item multiple times to the order.

0 Likes 0 ·

Welcome to the
Clover Developer Community