cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

create multiple entry for same product

Former Member
0 Likes
514

Hi Team,

I have a requirement to create multiple line items or entries for the same product based on the promotion applied.

Eg: If there is a BXGY promotion configured for 5 qualifying quantity of X , get 2 Y quantity free, and if customer adds 8 quantity of X product , then 5 quantity which is the actual promo qualifying quantity will go to 1 entry and the rest 3 quantity will go to another entry.

In my view cart flow, I am trying to update the existing entry with 5 quantity and creating a new entry with 3 quantity with the help of below codes, but always it creates 2 entries with 5 quantity each.

This is for updating the entry :

final CommerceCartParameter updateCartParameter = new CommerceCartParameter(); updateCartParameter.setEnableHooks(true); updateCartParameter.setCart(cartModel); updateCartParameter.setEntryNumber(entry.getEntryNumber().longValue()); updateCartParameter.setQuantity(5);

if (Objects.nonNull(pointOfServiceModel)) { updateCartParameter.setPointOfService(pointOfServiceModel); }

commerceCartService.updateQuantityForCartEntry(updateCartParameter);

Below code is for creating a new entry :

final CommerceCartParameter parameter = new CommerceCartParameter();

parameter.setEnableHooks(true); parameter.setCart(cartModel);

parameter.setProduct(entry.getProduct());

parameter.setPointOfService(pointOfServiceModel); parameter.setEntryNumber(nextEntryNumber);

parameter.setQuantity(3); parameter.setUnit(entry.getProduct().getUnit()); parameter.setCreateNewEntry(true); parameter.setClusterProduct(entry.getClusterProduct()); parameter.setRecalculate(false);

commerceCartService.addToCart(parameter);


Any suggestion would be really appreciated.

Thanks,

Kesari jena

Accepted Solutions (0)

Answers (0)