Search in sources :

Example 21 with FulfillmentGroup

use of org.broadleafcommerce.core.order.domain.FulfillmentGroup in project BroadleafCommerce by BroadleafCommerce.

the class BroadleafShippingInfoController method saveMultiShipInstruction.

public String saveMultiShipInstruction(HttpServletRequest request, HttpServletResponse response, Model model, MultiShipInstructionForm instructionForm) throws ServiceException, PricingException {
    Order cart = CartState.getCart();
    FulfillmentGroup fulfillmentGroup = null;
    for (FulfillmentGroup tempFulfillmentGroup : cart.getFulfillmentGroups()) {
        if (tempFulfillmentGroup.getId().equals(instructionForm.getFulfillmentGroupId())) {
            fulfillmentGroup = tempFulfillmentGroup;
        }
    }
    fulfillmentGroup.setPersonalMessage(instructionForm.getPersonalMessage());
    fulfillmentGroup.setDeliveryInstruction(instructionForm.getDeliveryMessage());
    fulfillmentGroupService.save(fulfillmentGroup);
    // append current time to redirect to fix a problem with ajax caching in IE
    return getCheckoutPageRedirect() + "?_=" + System.currentTimeMillis();
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup)

Example 22 with FulfillmentGroup

use of org.broadleafcommerce.core.order.domain.FulfillmentGroup in project BroadleafCommerce by BroadleafCommerce.

the class GoogleUniversalAnalyticsProcessor method getItemJs.

protected String getItemJs(Order order, String trackerPrefix) {
    StringBuffer sb = new StringBuffer();
    for (FulfillmentGroup fulfillmentGroup : order.getFulfillmentGroups()) {
        for (FulfillmentGroupItem fulfillmentGroupItem : fulfillmentGroup.getFulfillmentGroupItems()) {
            OrderItem orderItem = fulfillmentGroupItem.getOrderItem();
            Sku sku = ((SkuAccessor) orderItem).getSku();
            sb.append("ga('" + trackerPrefix + "ecommerce:addItem', {");
            sb.append("'id': '" + order.getOrderNumber() + "'");
            sb.append(",'name': '" + sku.getName() + "'");
            sb.append(",'sku': '" + sku.getId() + "'");
            sb.append(",'category': '" + getVariation(orderItem) + "'");
            sb.append(",'price': '" + orderItem.getAveragePrice() + "'");
            sb.append(",'quantity': '" + orderItem.getQuantity() + "'");
            sb.append("});");
        }
    }
    return sb.toString();
}
Also used : FulfillmentGroupItem(org.broadleafcommerce.core.order.domain.FulfillmentGroupItem) OrderItem(org.broadleafcommerce.core.order.domain.OrderItem) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) Sku(org.broadleafcommerce.core.catalog.domain.Sku) SkuAccessor(org.broadleafcommerce.core.order.domain.SkuAccessor)

Example 23 with FulfillmentGroup

use of org.broadleafcommerce.core.order.domain.FulfillmentGroup in project BroadleafCommerce by BroadleafCommerce.

the class FulfillmentGroupServiceImpl method addFulfillmentGroupToOrder.

@Override
@Transactional("blTransactionManager")
public FulfillmentGroup addFulfillmentGroupToOrder(FulfillmentGroupRequest fulfillmentGroupRequest, boolean priceOrder) throws PricingException {
    FulfillmentGroup fg = fulfillmentGroupDao.create();
    fg.setAddress(fulfillmentGroupRequest.getAddress());
    fg.setOrder(fulfillmentGroupRequest.getOrder());
    fg.setPhone(fulfillmentGroupRequest.getPhone());
    fg.setFulfillmentOption(fulfillmentGroupRequest.getOption());
    fg.setType(fulfillmentGroupRequest.getFulfillmentType());
    for (int i = 0; i < fulfillmentGroupRequest.getFulfillmentGroupItemRequests().size(); i++) {
        FulfillmentGroupItemRequest request = fulfillmentGroupRequest.getFulfillmentGroupItemRequests().get(i);
        request.setFulfillmentGroup(fg);
        request.setOrder(fulfillmentGroupRequest.getOrder());
        boolean shouldPriceOrder = (priceOrder && (i == (fulfillmentGroupRequest.getFulfillmentGroupItemRequests().size() - 1)));
        fg = addItemToFulfillmentGroup(request, shouldPriceOrder);
    }
    return fg;
}
Also used : FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) FulfillmentGroupItemRequest(org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 24 with FulfillmentGroup

use of org.broadleafcommerce.core.order.domain.FulfillmentGroup in project BroadleafCommerce by BroadleafCommerce.

the class FulfillmentGroupServiceImpl method calculateNumShippableFulfillmentGroups.

@Override
public Integer calculateNumShippableFulfillmentGroups(Order order) {
    Integer numShippableFulfillmentGroups = 0;
    List<FulfillmentGroup> fulfillmentGroups = order.getFulfillmentGroups();
    for (FulfillmentGroup fulfillmentGroup : CollectionUtils.emptyIfNull(fulfillmentGroups)) {
        if (isShippable(fulfillmentGroup.getType())) {
            numShippableFulfillmentGroups++;
        }
    }
    return numShippableFulfillmentGroups;
}
Also used : FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup)

Example 25 with FulfillmentGroup

use of org.broadleafcommerce.core.order.domain.FulfillmentGroup in project BroadleafCommerce by BroadleafCommerce.

the class FulfillmentGroupOfferProcessorImpl method calculateFulfillmentGroupTotal.

@Override
public void calculateFulfillmentGroupTotal(PromotableOrder order) {
    Money totalFulfillmentCharges = BroadleafCurrencyUtils.getMoney(BigDecimal.ZERO, order.getOrderCurrency());
    for (PromotableFulfillmentGroup fulfillmentGroupMember : order.getFulfillmentGroups()) {
        FulfillmentGroup fulfillmentGroup = fulfillmentGroupMember.getFulfillmentGroup();
        Money fulfillmentCharges;
        if (fulfillmentGroup.getShippingOverride()) {
            fulfillmentCharges = fulfillmentGroup.getFulfillmentPrice();
        } else {
            fulfillmentCharges = fulfillmentGroupMember.getFinalizedPriceWithAdjustments();
            fulfillmentGroupMember.getFulfillmentGroup().setFulfillmentPrice(fulfillmentCharges);
        }
        totalFulfillmentCharges = totalFulfillmentCharges.add(fulfillmentCharges);
    }
    order.setTotalFufillmentCharges(totalFulfillmentCharges);
}
Also used : Money(org.broadleafcommerce.common.money.Money) PromotableFulfillmentGroup(org.broadleafcommerce.core.offer.service.discount.domain.PromotableFulfillmentGroup) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) PromotableFulfillmentGroup(org.broadleafcommerce.core.offer.service.discount.domain.PromotableFulfillmentGroup)

Aggregations

FulfillmentGroup (org.broadleafcommerce.core.order.domain.FulfillmentGroup)67 FulfillmentGroupItem (org.broadleafcommerce.core.order.domain.FulfillmentGroupItem)39 Order (org.broadleafcommerce.core.order.domain.Order)32 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)24 Money (org.broadleafcommerce.common.money.Money)22 OrderItem (org.broadleafcommerce.core.order.domain.OrderItem)19 Transactional (org.springframework.transaction.annotation.Transactional)17 ArrayList (java.util.ArrayList)16 BundleOrderItem (org.broadleafcommerce.core.order.domain.BundleOrderItem)15 Address (org.broadleafcommerce.profile.core.domain.Address)15 Test (org.testng.annotations.Test)12 Sku (org.broadleafcommerce.core.catalog.domain.Sku)9 FulfillmentGroupImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupImpl)9 FulfillmentGroupItemImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl)8 Customer (org.broadleafcommerce.profile.core.domain.Customer)8 HashMap (java.util.HashMap)7 BigDecimal (java.math.BigDecimal)6 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)6 DiscreteOrderItemImpl (org.broadleafcommerce.core.order.domain.DiscreteOrderItemImpl)6 ISOCountry (org.broadleafcommerce.common.i18n.domain.ISOCountry)5