@Override public ShoppingCart populateAddressAndShippingFields( final ShoppingCart shoppingCart, final CartOrder cartOrder) { Address billingAddress = getBillingAddress(cartOrder); shoppingCart.setBillingAddress(billingAddress); Address shippingAddress = getShippingAddress(cartOrder); shoppingCart.setShippingAddress(shippingAddress); Store store = shoppingCart.getStore(); List<ShippingServiceLevel> shippingServiceLevels = shippingServiceLevelService.retrieveShippingServiceLevel(store.getCode(), shippingAddress); if (CollectionUtils.isNotEmpty(shippingServiceLevels)) { String shippingServiceLevelGuidFromCartOrder = cartOrder.getShippingServiceLevelGuid(); ShippingServiceLevel matchingShippingServiceLevel = getShippingServiceLevelMatchingGuid( shippingServiceLevels, shippingServiceLevelGuidFromCartOrder); if (matchingShippingServiceLevel != null) { shoppingCart.setShippingServiceLevelList(shippingServiceLevels); shoppingCart.setSelectedShippingServiceLevelUid(matchingShippingServiceLevel.getUidPk()); } } return shoppingCart; }
private ShippingServiceLevel getShippingServiceLevelMatchingGuid( final List<ShippingServiceLevel> shippingServiceLevels, final String shippingServiceLevelGuid) { for (ShippingServiceLevel currentShippingServiceLevel : shippingServiceLevels) { String currentShippingServiceLevelGuid = currentShippingServiceLevel.getGuid(); if (currentShippingServiceLevelGuid.equals(shippingServiceLevelGuid)) { return currentShippingServiceLevel; } } return null; }