Package org.broadleafcommerce.core.order.service.call

Examples of org.broadleafcommerce.core.order.service.call.FulfillmentGroupRequest


    public FulfillmentGroupWrapper addFulfillmentGroupToOrder(HttpServletRequest request,
            FulfillmentGroupWrapper wrapper,
            boolean priceOrder) {
        Order cart = CartState.getCart();
        if (cart != null) {
            FulfillmentGroupRequest fulfillmentGroupRequest = wrapper.unwrap(request, context);

            if (fulfillmentGroupRequest.getOrder() != null && fulfillmentGroupRequest.getOrder().getId().equals(cart.getId())) {
                try {
                    fulfillmentGroupRequest.setOrder(cart);
                    FulfillmentGroup fulfillmentGroup = fulfillmentGroupService.addFulfillmentGroupToOrder(fulfillmentGroupRequest, priceOrder);
                    FulfillmentGroupWrapper fulfillmentGroupWrapper = (FulfillmentGroupWrapper) context.getBean(FulfillmentGroupWrapper.class.getName());
                    fulfillmentGroupWrapper.wrapDetails(fulfillmentGroup, request);
                    return fulfillmentGroupWrapper;
                } catch (PricingException e) {
View Full Code Here


        wrapDetails(model, request);
    }

    @Override
    public FulfillmentGroupRequest unwrap(HttpServletRequest request, ApplicationContext appContext) {
        FulfillmentGroupRequest fulfillmentGroupRequest = new FulfillmentGroupRequest();

        List<FulfillmentGroupItemRequest> fulfillmentGroupItemRequests = new ArrayList<FulfillmentGroupItemRequest>();
        for (FulfillmentGroupItemWrapper wrapper : this.fulfillmentGroupItems) {
            fulfillmentGroupItemRequests.add(wrapper.unwrap(request, appContext));
        }

        fulfillmentGroupRequest.setFulfillmentGroupItemRequests(fulfillmentGroupItemRequests);

        OrderService orderService = (OrderService) appContext.getBean("blOrderService");
        Order order = orderService.findOrderById(this.orderId);
        if (order != null) {
            fulfillmentGroupRequest.setOrder(order);
        }

        if (this.address != null) {
            fulfillmentGroupRequest.setAddress(this.address.unwrap(request, appContext));
        }

        if (this.phone != null) {
            fulfillmentGroupRequest.setPhone(this.phone.unwrap(request, appContext));
        }

        if (this.fulfillmentOption != null && this.fulfillmentOption.getId() != null) {
            FulfillmentOptionService fulfillmentOptionService = (FulfillmentOptionService) appContext.getBean("blFulfillmentOptionService");
            FulfillmentOption option = fulfillmentOptionService.readFulfillmentOptionById(this.fulfillmentOption.getId());
            fulfillmentGroupRequest.setOption(option);
        }

        return fulfillmentGroupRequest;
    }
View Full Code Here

        sr2 = shippingRateService.save(sr2);
        Customer customer = createCustomerWithAddresses();
        Order order = initializeExistingCart(customer);
        CustomerAddress customerAddress = customerAddressService.readActiveCustomerAddressesByCustomerId(customer.getId()).get(0);
       
        FulfillmentGroupRequest fgRequest = new FulfillmentGroupRequest();
       
        List<FulfillmentGroupItemRequest> fgiRequests = new ArrayList<FulfillmentGroupItemRequest>();

        for (OrderItem orderItem : order.getOrderItems()) {
            FulfillmentGroupItemRequest fgiRequest = new FulfillmentGroupItemRequest();
            fgiRequest.setOrderItem(orderItem);
            fgiRequest.setQuantity(1);
            fgiRequests.add(fgiRequest);
        }
       
        fgRequest.setAddress(customerAddress.getAddress());
        fgRequest.setFulfillmentGroupItemRequests(fgiRequests);
        fgRequest.setOrder(cartService.findCartForCustomer(customer));
        fgRequest.setMethod("standard");
        fgRequest.setService(ShippingServiceType.BANDED_SHIPPING.getType());
        cartService.addFulfillmentGroupToOrder(fgRequest);
       
        Order resultOrder = cartService.findOrderById(order.getId());
        assert resultOrder.getFulfillmentGroups().size() == 1;
        assert resultOrder.getFulfillmentGroups().get(0).getFulfillmentGroupItems().size() == 2;
View Full Code Here

        }

        if (fulfillmentGroup == null) {
            // API user is trying to add an item to a fulfillment group not created
            fulfillmentGroup = fulfillmentGroupDao.create();
            FulfillmentGroupRequest fgRequest = new FulfillmentGroupRequest();
            fgRequest.setOrder(order);
            fulfillmentGroup = addFulfillmentGroupToOrder(fgRequest, false);
            fulfillmentGroup = save(fulfillmentGroup);
            order.getFulfillmentGroups().add(fulfillmentGroup);
        }
View Full Code Here

            String key = getKey(option.getAddress(), option.getFulfillmentOption(), ((DiscreteOrderItem) option.getOrderItem()).getSku().getFulfillmentType());
            FulfillmentGroup fg = multishipGroups.get(key);
           
            // Get or create a fulfillment group that matches this OrderMultishipOption destination
            if (fg == null) {
                FulfillmentGroupRequest fgr = new FulfillmentGroupRequest();
               
                fgr.setOrder(order);
               
                if (option.getAddress() != null) {
                    fgr.setAddress(option.getAddress());
                }
               
                if (option.getFulfillmentOption() != null) {
                    fgr.setOption(option.getFulfillmentOption());
                }
               
                fgr.setFulfillmentType(((DiscreteOrderItem) option.getOrderItem()).getSku().getFulfillmentType());

                fg = addFulfillmentGroupToOrder(fgr, false);
                fg = save(fg);
                order.getFulfillmentGroups().add(fg);
            }
View Full Code Here

TOP

Related Classes of org.broadleafcommerce.core.order.service.call.FulfillmentGroupRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.