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

Removing Point of Service from Cart Entry

Former Member
0 Kudos
367

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

Thanks for the answer. Well, the reason for removing the pos from the entry is to update the cart by changing the delivery mode of the cart, here our requirement is to have one kind of delivery mode for Cart.so I need to remove other entries which are not eligible for pickup and updating the pos to null which are not eligible for pickup.

I have used ootb updateCartentry method to update the pos for Home delivery cs it accepts null in pos thereby updating the pos of each cart entry as null.

Anyway, your answer has given some idea and i will follow the same.

Thanks