question

dhanaraj avatar image
dhanaraj asked zgreathouse Deactivated answered

how to add modifiers price and modifier name in clover payment?

while we going to pay the amount for an order modifier price and modifier name is not shown in the clover payment page and it will take only line item price.

inventoryConnector.connect();
orderConnector.connect();
mOrder = orderConnector.getOrder(mOrderId);
for (int i = 0; i < lst_selectedItem.size(); i++) {

Long s = lst_selectedItem.get(i).getItem_Price();
Long ds = 0l;
if(lst_selectedItem.get(i).getModiferPrice()!=null)
{
ds =Long.valueOf(lst_selectedItem.get(i).getModiferPrice());
}
Long count = s+ds;
lst_selectedItem.get(i).setItem_Price(count);
mItem = inventoryConnector.getItem(lst_selectedItem.get(i).getItem_Id());

for (int j = 0; j < lst_selectedItem.get(i).getItem_Count(); j++) {
if (mItem.getPriceType() == PriceType.FIXED) {


mLineItem = orderConnector.addFixedPriceLineItem(mOrder.getId(), mItem.getId(), null, null);

} else if (mItem.getPriceType() == PriceType.PER_UNIT) {
mLineItem = orderConnector.addPerUnitLineItem(mOrder.getId(), mItem.getId(), mItem.getStockCount().intValue(), null, null);

} else { // The item must be of a VARIABLE PriceTypemLineItem = orderConnector.addVariablePriceLineItem(mOrder.getId(), mItem.getId(), mItem.getPrice(), null, null);
}
mLineItem.setPriceWithModifiersAndItemAndOrderDiscounts(Long.valueOf(lst_selectedItem.get(i).getModiferPrice()));
Modifier modificationObject=new Modifier();
modificationObject.setName("sample");
// modificationObject.setPrice(Long.valueOf(lst_selectedItem.get(i).getModiferPrice())); //orderConnector.addLineItemModification(mOrder.getId(), mItem.getId(), modificationObject);List<Modification> modificationList=new ArrayList<>();
Modification modification=new Modification();
modification.setModifier(modificationObject);
modificationList.add(modification);
mLineItem.setModifications(modificationList);
mLineItem.setPriceWithModifiers(modificationObject.getPrice());

lineItemList.add(mLineItem);

}
mOrder.setLineItems(lineItemList);

}


if (mdiscounts != null) {
for (int j = 0; j < mdiscounts.size(); j++) {
orderConnector.addDiscount(mOrder.getId(), mdiscounts.get(j));
}

}

mOrderList.add(mOrder);
object = mOrderList;
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.

1 Answer

zgreathouse avatar image
zgreathouse Deactivated answered
You cannot create Custom Modifiers. In order to apply a Modifier to a Line Item, the Modifier Group the Modifier belongs to must already have been *created and then *associated with the Line Item's Item.

To add an existing modifier to a lineItem you would use the addLineItemModification method.
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