on ‎2018 Aug 12 2:02 PM
Hi All
i had a requirement to update the cart entry based on delivery mode. So i had to remove the Point of service from cart entry if the delivery mode changes. is there any ootb logic to update the cart entry by removing the pos from entry
Thanks.
Request clarification before answering.
Hi : Why do you want to remove PointOfService from cart entry ?
do you want to show a message on each cart item level that this product is not available for pickup or do you want to show a message at order level ?
We had a similar requirement where we wanted 'Women' products to be available for express delivery and pick up in store while 'Kids' product should only be available for standard delivery.
Solution, have delivery modes at the product level, OOB you get a one to many relationship between product & delivery modes.
Write your own custom strategy like below:
public void getDeliveryCodes(final AbstractOrderModel abstractOrderModel, final Set<String> deliveryCodes)
{
final Map<String, AtomicLong> deliveryModeMap = new HashMap<>();
for (final AbstractOrderEntryModel entries : abstractOrderModel.getEntries())
{
if (CollectionUtils.isNotEmpty(entries.getProduct().getDeliveryModes()))
{
for (final DeliveryModeModel deliveryMode : entries.getProduct().getDeliveryModes())
{
final String code = deliveryMode.getCode();
if (null == deliveryModeMap.get(code))
{
deliveryModeMap.put(code, new AtomicLong(1L));
}
else
{
deliveryModeMap.get(code).incrementAndGet();
}
}
}
}
for (final Entry<String, AtomicLong> entry : deliveryModeMap.entrySet())
{
if (entry.getValue().get() == abstractOrderModel.getEntries().size())
{
deliveryCodes.add(entry.getKey());
}
}
}
Basically a deliveryMode which is present in all product items will have an atomic long value equals cartEntry size.
So even if a 100 products are eligible for express/standard/pickUp and a single product is eligible for only standard, the whole cart becomes eligible for just standard.
Hope it helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.