question

Mateus avatar image
Mateus asked ·

Can I change the name of a variable price line item?

I'm using a variable price inventory item to add a tax that can't be implemented via Tax Rates. As the user adds liquors to an order, I add those variable price items(one for each liquor). Let's say the name of this item is "Tax XYZ". I'd like to have something like this, though, on the register/receipts:
Tax XYZ (750mL) 1.86
Tax XYZ (250mL) 0.92

In other words, custom names for different line items backed by the same variable price inventory item. Is it possible? My current solution is to use binName.
OrdersInventoryLineItems
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

Miguel avatar image
Miguel answered ·
Hi @Mateus
I just tried the following in our Android SDK, and it seems to do what you're looking for:
Item item = mInventoryConnector.getItem("TZ8EERTEG74XR");
item.setName("Name A");
mInventoryConnector.updateItem(item);
mOrderConnector.addVariablePriceLineItem(order.getId(), item.getId(), 100, null, null);
item.setName("Name B");
mInventoryConnector.updateItem(item);
mOrderConnector.addVariablePriceLineItem(order.getId(), item.getId(), 200, null, null);
item.setName("Original Name");
mInventoryConnector.updateItem(item);
The only caveat I found was that if the price was the same, the items were grouped by together. In my example above, if the second item was priced at 100, it would list two "Name A" at $1 on the order.
4 comments 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.

Another caveat is that this will permanently change the name of the item in the inventory. I was hoping to change the line item name only. Thanks for your help!

0 Likes 0 · ·

You could set the name back to the original at the end.

1 Like 1 · ·

I'm not sure this is what you actually want to do. If two devices are both modifying the same item to apply the temporary name, results will be unpredictable. This also mutates the item twice in addition to adding the line item.

It sounds like what you are trying to do is apply a flat tax to the order for each volume of liquor sold. The closest I can think of is adding a custom item with a specific name each time a bottle is added to the order, but I don't know if that is a good idea/meets your requirements.

1 Like 1 · ·

Thanks for the warning, very true.

I can't use custom items, as I need the line items to be backed by inventory items.

0 Likes 0 · ·

Welcome to the
Clover Developer Community