Search in sources :

Example 31 with Address

use of org.broadleafcommerce.profile.core.domain.Address in project BroadleafCommerce by BroadleafCommerce.

the class OfferDataItemProvider method createBasicOrder.

public Order createBasicOrder() {
    Order order = new OrderImpl();
    order.setId(getOrderId());
    Category category1 = new CategoryImpl();
    category1.setName("test1");
    category1.setId(1L);
    Product product1 = new ProductImpl();
    Sku sku1 = new SkuImpl();
    sku1.setName("test1");
    sku1.setId(1L);
    sku1.setDiscountable(true);
    sku1.setRetailPrice(new Money(19.99D));
    product1.setDefaultSku(sku1);
    CategoryProductXref xref1 = new CategoryProductXrefImpl();
    xref1.setProduct(product1);
    xref1.setCategory(category1);
    category1.getAllProductXrefs().add(xref1);
    Category category2 = new CategoryImpl();
    category2.setName("test2");
    category2.setId(2L);
    Product product2 = new ProductImpl();
    Sku sku2 = new SkuImpl();
    sku2.setName("test2");
    sku2.setId(2L);
    sku2.setDiscountable(true);
    sku2.setRetailPrice(new Money(29.99D));
    product2.setDefaultSku(sku2);
    CategoryProductXref xref2 = new CategoryProductXrefImpl();
    xref2.setProduct(product2);
    xref2.setCategory(category2);
    category2.getAllProductXrefs().add(xref2);
    DiscreteOrderItem orderItem1 = new DiscreteOrderItemImpl();
    orderItem1.setCategory(category1);
    orderItem1.setName("test1");
    orderItem1.setOrder(order);
    orderItem1.setOrderItemType(OrderItemType.DISCRETE);
    orderItem1.setProduct(product1);
    orderItem1.setQuantity(2);
    orderItem1.setSku(sku1);
    orderItem1.setId(getOrderItemId());
    orderItem1.setOrder(order);
    OrderItemPriceDetail priceDetail1 = new OrderItemPriceDetailImpl();
    priceDetail1.setOrderItem(orderItem1);
    priceDetail1.setQuantity(2);
    orderItem1.getOrderItemPriceDetails().add(priceDetail1);
    order.getOrderItems().add(orderItem1);
    DiscreteOrderItem orderItem2 = new DiscreteOrderItemImpl();
    orderItem2.setCategory(category2);
    orderItem2.setName("test2");
    orderItem2.setOrder(order);
    orderItem2.setOrderItemType(OrderItemType.DISCRETE);
    orderItem2.setProduct(product2);
    orderItem2.setQuantity(3);
    orderItem2.setSku(sku2);
    orderItem2.setId(getOrderItemId());
    orderItem2.setOrder(order);
    OrderItemPriceDetail priceDetail2 = new OrderItemPriceDetailImpl();
    priceDetail2.setOrderItem(orderItem2);
    priceDetail2.setQuantity(3);
    orderItem2.getOrderItemPriceDetails().add(priceDetail2);
    order.getOrderItems().add(orderItem2);
    Customer customer = new CustomerImpl();
    customer.setEmailAddress("test@test.com");
    customer.setFirstName("John");
    customer.setLastName("Tester");
    customer.setReceiveEmail(true);
    customer.setRegistered(true);
    order.setCustomer(customer);
    order.setEmailAddress("test@test.com");
    FulfillmentGroup fg1 = new FulfillmentGroupImpl();
    fg1.setId(1L);
    Address address1 = new AddressImpl();
    address1.setAddressLine1("123 Test Road");
    address1.setCity("Dallas");
    Country country = new CountryImpl();
    country.setAbbreviation("US");
    country.setName("United States");
    ISOCountry isoCountry = new ISOCountryImpl();
    isoCountry.setAlpha2("US");
    isoCountry.setName("UNITED STATES");
    address1.setCountry(country);
    address1.setIsoCountryAlpha2(isoCountry);
    address1.setDefault(true);
    address1.setFirstName("John");
    address1.setLastName("Tester");
    address1.setPostalCode("75244");
    Phone primary = new PhoneImpl();
    primary.setPhoneNumber("972-976-1234");
    address1.setPhonePrimary(primary);
    State state = new StateImpl();
    state.setAbbreviation("TX");
    state.setCountry(country);
    state.setName("Texas");
    address1.setState(state);
    address1.setIsoCountrySubdivision("US-TX");
    fg1.setAddress(address1);
    fg1.setOrder(order);
    fg1.setPrimary(true);
    fg1.setRetailShippingPrice(new Money(10D));
    fg1.setShippingPrice(new Money(10D));
    fg1.setType(FulfillmentType.PHYSICAL_SHIP);
    fg1.setOrder(order);
    FulfillmentGroupItem fgItem1 = new FulfillmentGroupItemImpl();
    fgItem1.setFulfillmentGroup(fg1);
    fgItem1.setOrderItem(orderItem1);
    fgItem1.setQuantity(2);
    // fgItem1.setRetailPrice(new Money(19.99D));
    fg1.getFulfillmentGroupItems().add(fgItem1);
    order.getFulfillmentGroups().add(fg1);
    FulfillmentGroup fg2 = new FulfillmentGroupImpl();
    fg2.setId(2L);
    Address address2 = new AddressImpl();
    address2.setAddressLine1("124 Test Road");
    address2.setCity("Dallas");
    Country country2 = new CountryImpl();
    country2.setAbbreviation("US");
    country2.setName("United States");
    ISOCountry isoCountry2 = new ISOCountryImpl();
    isoCountry2.setAlpha2("US");
    isoCountry2.setName("UNITED STATES");
    address2.setCountry(country2);
    address2.setIsoCountryAlpha2(isoCountry2);
    address2.setDefault(true);
    address2.setFirstName("John");
    address2.setLastName("Tester");
    address2.setPostalCode("75244");
    Phone primary2 = new PhoneImpl();
    primary2.setPhoneNumber("972-976-1234");
    address2.setPhonePrimary(primary2);
    State state2 = new StateImpl();
    state2.setAbbreviation("TX");
    state2.setCountry(country2);
    state2.setName("Texas");
    address2.setState(state2);
    address2.setIsoCountrySubdivision("US-TX");
    fg2.setAddress(address2);
    fg2.setOrder(order);
    fg2.setPrimary(true);
    fg2.setRetailShippingPrice(new Money(20D));
    fg2.setShippingPrice(new Money(20D));
    fg2.setType(FulfillmentType.PHYSICAL_SHIP);
    fg2.setOrder(order);
    FulfillmentGroupItem fgItem2 = new FulfillmentGroupItemImpl();
    fgItem2.setFulfillmentGroup(fg2);
    fgItem2.setOrderItem(orderItem2);
    fgItem2.setQuantity(3);
    // fgItem2.setRetailPrice(new Money(29.99D));
    fg2.getFulfillmentGroupItems().add(fgItem2);
    order.getFulfillmentGroups().add(fg2);
    order.setSubTotal(new Money((2 * 19.99D) + (3 * 29.99D)));
    orders.put(order.getId(), order);
    return order;
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) Category(org.broadleafcommerce.core.catalog.domain.Category) CategoryProductXref(org.broadleafcommerce.core.catalog.domain.CategoryProductXref) Address(org.broadleafcommerce.profile.core.domain.Address) DiscreteOrderItemImpl(org.broadleafcommerce.core.order.domain.DiscreteOrderItemImpl) Customer(org.broadleafcommerce.profile.core.domain.Customer) OrderItemPriceDetailImpl(org.broadleafcommerce.core.order.domain.OrderItemPriceDetailImpl) Product(org.broadleafcommerce.core.catalog.domain.Product) CustomerImpl(org.broadleafcommerce.profile.core.domain.CustomerImpl) Money(org.broadleafcommerce.common.money.Money) ISOCountryImpl(org.broadleafcommerce.common.i18n.domain.ISOCountryImpl) CountryImpl(org.broadleafcommerce.profile.core.domain.CountryImpl) Phone(org.broadleafcommerce.profile.core.domain.Phone) FulfillmentGroupItem(org.broadleafcommerce.core.order.domain.FulfillmentGroupItem) CategoryProductXrefImpl(org.broadleafcommerce.core.catalog.domain.CategoryProductXrefImpl) AddressImpl(org.broadleafcommerce.profile.core.domain.AddressImpl) PhoneImpl(org.broadleafcommerce.profile.core.domain.PhoneImpl) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) ISOCountryImpl(org.broadleafcommerce.common.i18n.domain.ISOCountryImpl) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) FulfillmentGroupItemImpl(org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl) PromotableOrder(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder) Order(org.broadleafcommerce.core.order.domain.Order) FulfillmentGroupImpl(org.broadleafcommerce.core.order.domain.FulfillmentGroupImpl) StateImpl(org.broadleafcommerce.profile.core.domain.StateImpl) CategoryImpl(org.broadleafcommerce.core.catalog.domain.CategoryImpl) SkuImpl(org.broadleafcommerce.core.catalog.domain.SkuImpl) ProductImpl(org.broadleafcommerce.core.catalog.domain.ProductImpl) State(org.broadleafcommerce.profile.core.domain.State) OrderImpl(org.broadleafcommerce.core.order.domain.OrderImpl) PromotableOrderImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderImpl) Country(org.broadleafcommerce.profile.core.domain.Country) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) OrderItemPriceDetail(org.broadleafcommerce.core.order.domain.OrderItemPriceDetail) Sku(org.broadleafcommerce.core.catalog.domain.Sku)

Example 32 with Address

use of org.broadleafcommerce.profile.core.domain.Address in project BroadleafCommerce by BroadleafCommerce.

the class FulfillmentGroupOfferProcessorTest method testApplyAllFulfillmentGroupOffersWithOrderItemOffers.

public void testApplyAllFulfillmentGroupOffersWithOrderItemOffers() throws Exception {
    final ThreadLocal<Order> myOrder = new ThreadLocal<Order>();
    EasyMock.expect(orderItemDaoMock.createOrderItemPriceDetail()).andAnswer(OfferDataItemProvider.getCreateOrderItemPriceDetailAnswer()).anyTimes();
    EasyMock.expect(orderItemDaoMock.createOrderItemQualifier()).andAnswer(OfferDataItemProvider.getCreateOrderItemQualifierAnswer()).atLeastOnce();
    EasyMock.expect(fgServiceMock.addItemToFulfillmentGroup(EasyMock.isA(FulfillmentGroupItemRequest.class), EasyMock.eq(false))).andAnswer(OfferDataItemProvider.getAddItemToFulfillmentGroupAnswer()).anyTimes();
    EasyMock.expect(orderServiceMock.removeItem(EasyMock.isA(Long.class), EasyMock.isA(Long.class), EasyMock.eq(false))).andAnswer(OfferDataItemProvider.getRemoveItemFromOrderAnswer()).anyTimes();
    EasyMock.expect(orderServiceMock.save(EasyMock.isA(Order.class), EasyMock.isA(Boolean.class))).andAnswer(OfferDataItemProvider.getSaveOrderAnswer()).anyTimes();
    EasyMock.expect(offerServiceUtilitiesMock.orderMeetsQualifyingSubtotalRequirements(EasyMock.isA(PromotableOrder.class), EasyMock.isA(Offer.class), EasyMock.isA(HashMap.class))).andReturn(true).anyTimes();
    EasyMock.expect(offerServiceUtilitiesMock.orderMeetsSubtotalRequirements(EasyMock.isA(PromotableOrder.class), EasyMock.isA(Offer.class))).andReturn(true).anyTimes();
    EasyMock.expect(orderServiceMock.getAutomaticallyMergeLikeItems()).andReturn(true).anyTimes();
    EasyMock.expect(orderItemServiceMock.saveOrderItem(EasyMock.isA(OrderItem.class))).andAnswer(OfferDataItemProvider.getSaveOrderItemAnswer()).anyTimes();
    EasyMock.expect(fgItemDaoMock.save(EasyMock.isA(FulfillmentGroupItem.class))).andAnswer(OfferDataItemProvider.getSaveFulfillmentGroupItemAnswer()).anyTimes();
    EasyMock.expect(offerDaoMock.createOrderItemPriceDetailAdjustment()).andAnswer(OfferDataItemProvider.getCreateOrderItemPriceDetailAdjustmentAnswer()).anyTimes();
    EasyMock.expect(offerDaoMock.createFulfillmentGroupAdjustment()).andAnswer(OfferDataItemProvider.getCreateFulfillmentGroupAdjustmentAnswer()).anyTimes();
    EasyMock.expect(orderServiceMock.findOrderById(EasyMock.isA(Long.class))).andAnswer(new IAnswer<Order>() {

        @Override
        public Order answer() throws Throwable {
            return myOrder.get();
        }
    }).anyTimes();
    EasyMock.expect(multishipOptionServiceMock.findOrderMultishipOptions(EasyMock.isA(Long.class))).andAnswer(new IAnswer<List<OrderMultishipOption>>() {

        @Override
        public List<OrderMultishipOption> answer() throws Throwable {
            List<OrderMultishipOption> options = new ArrayList<OrderMultishipOption>();
            PromotableOrder order = dataProvider.createBasicPromotableOrder();
            for (FulfillmentGroup fg : order.getOrder().getFulfillmentGroups()) {
                Address address = fg.getAddress();
                for (FulfillmentGroupItem fgItem : fg.getFulfillmentGroupItems()) {
                    for (int j = 0; j < fgItem.getQuantity(); j++) {
                        OrderMultishipOption option = new OrderMultishipOptionImpl();
                        option.setOrder(order.getOrder());
                        option.setAddress(address);
                        option.setOrderItem(fgItem.getOrderItem());
                        options.add(option);
                    }
                }
            }
            return options;
        }
    }).anyTimes();
    multishipOptionServiceMock.deleteAllOrderMultishipOptions(EasyMock.isA(Order.class));
    EasyMock.expectLastCall().anyTimes();
    EasyMock.expect(fgServiceMock.collapseToOneShippableFulfillmentGroup(EasyMock.isA(Order.class), EasyMock.eq(false))).andAnswer(new IAnswer<Order>() {

        @Override
        public Order answer() throws Throwable {
            Order order = (Order) EasyMock.getCurrentArguments()[0];
            order.getFulfillmentGroups().get(0).getFulfillmentGroupItems().addAll(order.getFulfillmentGroups().get(1).getFulfillmentGroupItems());
            order.getFulfillmentGroups().remove(order.getFulfillmentGroups().get(1));
            return order;
        }
    }).anyTimes();
    EasyMock.expect(fgItemDaoMock.create()).andAnswer(OfferDataItemProvider.getCreateFulfillmentGroupItemAnswer()).anyTimes();
    fgItemDaoMock.delete(EasyMock.isA(FulfillmentGroupItem.class));
    EasyMock.expectLastCall().anyTimes();
    EasyMock.expect(offerTimeZoneProcessorMock.getTimeZone(EasyMock.isA(OfferImpl.class))).andReturn(TimeZone.getTimeZone("CST")).anyTimes();
    replay();
    PromotableOrder promotableOrder = dataProvider.createBasicPromotableOrder();
    Order order = promotableOrder.getOrder();
    myOrder.set(promotableOrder.getOrder());
    List<PromotableCandidateFulfillmentGroupOffer> qualifiedOffers = new ArrayList<PromotableCandidateFulfillmentGroupOffer>();
    List<Offer> offers = dataProvider.createFGBasedOffer("order.subTotal.getAmount()>20", "fulfillmentGroup.address.postalCode==75244", OfferDiscountType.PERCENT_OFF);
    offers.addAll(dataProvider.createFGBasedOfferWithItemCriteria("order.subTotal.getAmount()>20", "fulfillmentGroup.address.postalCode==75244", OfferDiscountType.PERCENT_OFF, "([MVEL.eval(\"toUpperCase()\",\"test1\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))"));
    offers.get(1).setName("secondOffer");
    offers.addAll(dataProvider.createItemBasedOfferWithItemCriteria("order.subTotal.getAmount()>20", OfferDiscountType.PERCENT_OFF, "([MVEL.eval(\"toUpperCase()\",\"test1\"), MVEL.eval(\"toUpperCase()\",\"test2\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))", "([MVEL.eval(\"toUpperCase()\",\"test1\"), MVEL.eval(\"toUpperCase()\",\"test2\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))"));
    offerService.applyAndSaveOffersToOrder(offers, promotableOrder.getOrder());
    offers.get(0).setTotalitarianOffer(true);
    offerService.applyAndSaveFulfillmentGroupOffersToOrder(offers, promotableOrder.getOrder());
    int fgAdjustmentCount = 0;
    for (FulfillmentGroup fg : order.getFulfillmentGroups()) {
        fgAdjustmentCount += fg.getFulfillmentGroupAdjustments().size();
    }
    // The totalitarian offer that applies to both fg's is not combinable and is a worse offer than the order item offers
    // - it is therefore ignored
    // However, the second combinable fg offer is allowed to be applied.
    assertTrue(fgAdjustmentCount == 1);
    promotableOrder = dataProvider.createBasicPromotableOrder();
    myOrder.set(promotableOrder.getOrder());
    offers.get(2).setValue(new BigDecimal("1"));
    offerService.applyAndSaveOffersToOrder(offers, promotableOrder.getOrder());
    offerService.applyAndSaveFulfillmentGroupOffersToOrder(offers, promotableOrder.getOrder());
    fgAdjustmentCount = 0;
    order = promotableOrder.getOrder();
    for (FulfillmentGroup fg : order.getFulfillmentGroups()) {
        fgAdjustmentCount += fg.getFulfillmentGroupAdjustments().size();
    }
    // The totalitarian fg offer is now a better deal than the order item offers, therefore the totalitarian fg offer is applied
    // and the order item offers are removed
    assertTrue(fgAdjustmentCount == 2);
    int itemAdjustmentCount = 0;
    for (OrderItem item : order.getOrderItems()) {
        for (OrderItemPriceDetail detail : item.getOrderItemPriceDetails()) {
            itemAdjustmentCount += detail.getOrderItemPriceDetailAdjustments().size();
        }
    }
    // Confirm that the order item offers are removed
    assertTrue(itemAdjustmentCount == 0);
    verify();
}
Also used : PromotableOrder(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder) Order(org.broadleafcommerce.core.order.domain.Order) Address(org.broadleafcommerce.profile.core.domain.Address) OrderMultishipOptionImpl(org.broadleafcommerce.core.order.domain.OrderMultishipOptionImpl) ArrayList(java.util.ArrayList) PromotableOrder(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder) BigDecimal(java.math.BigDecimal) IAnswer(org.easymock.IAnswer) CandidateFulfillmentGroupOffer(org.broadleafcommerce.core.offer.domain.CandidateFulfillmentGroupOffer) PromotableCandidateFulfillmentGroupOffer(org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateFulfillmentGroupOffer) CandidateItemOffer(org.broadleafcommerce.core.offer.domain.CandidateItemOffer) Offer(org.broadleafcommerce.core.offer.domain.Offer) FulfillmentGroupItem(org.broadleafcommerce.core.order.domain.FulfillmentGroupItem) PromotableOrderItem(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem) OrderItem(org.broadleafcommerce.core.order.domain.OrderItem) OrderMultishipOption(org.broadleafcommerce.core.order.domain.OrderMultishipOption) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) PromotableFulfillmentGroup(org.broadleafcommerce.core.offer.service.discount.domain.PromotableFulfillmentGroup) PromotableCandidateFulfillmentGroupOffer(org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateFulfillmentGroupOffer) OrderItemPriceDetail(org.broadleafcommerce.core.order.domain.OrderItemPriceDetail)

Example 33 with Address

use of org.broadleafcommerce.profile.core.domain.Address in project BroadleafCommerce by BroadleafCommerce.

the class BroadleafShippingInfoController method copyBillingAddressToShippingAddress.

/**
 * This method will copy the billing address of any CREDIT CARD order payment on the order
 * to the shipping address on the ShippingInfoForm that is passed in.
 */
protected void copyBillingAddressToShippingAddress(Order order, ShippingInfoForm shippingInfoForm) {
    if (order.getPayments() != null) {
        for (OrderPayment payment : order.getPayments()) {
            if (payment.isActive() && PaymentType.CREDIT_CARD.equals(payment.getType())) {
                Address billing = payment.getBillingAddress();
                if (billing != null) {
                    Address shipping = addressService.copyAddress(billing);
                    shippingInfoForm.setAddress(shipping);
                }
            }
        }
    }
}
Also used : Address(org.broadleafcommerce.profile.core.domain.Address) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) OrderPayment(org.broadleafcommerce.core.payment.domain.OrderPayment)

Example 34 with Address

use of org.broadleafcommerce.profile.core.domain.Address in project BroadleafCommerce by BroadleafCommerce.

the class BroadleafShippingInfoController method saveSingleShip.

/**
 * Processes the request to save a single shipping address.  Allows modules to add module specific shipping logic.
 *
 * Note:  the default Broadleaf implementation creates an order
 * with a single fulfillment group. In the case of shipping to multiple addresses,
 * the multiship methods should be used.
 *
 * @param request
 * @param response
 * @param model
 * @param shippingForm
 * @return the return path
 * @throws org.broadleafcommerce.common.exception.ServiceException
 */
public String saveSingleShip(HttpServletRequest request, HttpServletResponse response, Model model, ShippingInfoForm shippingForm, BindingResult result) throws PricingException, ServiceException {
    Order cart = CartState.getCart();
    if (shippingForm.shouldUseBillingAddress()) {
        copyBillingAddressToShippingAddress(cart, shippingForm);
    }
    addressService.populateAddressISOCountrySub(shippingForm.getAddress());
    shippingInfoFormValidator.validate(shippingForm, result);
    if (result.hasErrors()) {
        return getCheckoutView();
    }
    if ((shippingForm.getAddress().getPhonePrimary() != null) && (StringUtils.isEmpty(shippingForm.getAddress().getPhonePrimary().getPhoneNumber()))) {
        shippingForm.getAddress().setPhonePrimary(null);
    }
    if ((shippingForm.getAddress().getPhoneSecondary() != null) && (StringUtils.isEmpty(shippingForm.getAddress().getPhoneSecondary().getPhoneNumber()))) {
        shippingForm.getAddress().setPhoneSecondary(null);
    }
    if ((shippingForm.getAddress().getPhoneFax() != null) && (StringUtils.isEmpty(shippingForm.getAddress().getPhoneFax().getPhoneNumber()))) {
        shippingForm.getAddress().setPhoneFax(null);
    }
    Customer customer = CustomerState.getCustomer();
    if (!customer.isAnonymous() && shippingForm.isSaveAsDefault()) {
        Address address = addressService.saveAddress(shippingForm.getAddress());
        CustomerAddress customerAddress = customerAddressService.create();
        customerAddress.setAddress(address);
        customerAddress.setAddressName(shippingForm.getAddressName());
        customerAddress.setCustomer(customer);
        customerAddress = customerAddressService.saveCustomerAddress(customerAddress);
        customerAddressService.makeCustomerAddressDefault(customerAddress.getId(), customer.getId());
    }
    FulfillmentGroup shippableFulfillmentGroup = fulfillmentGroupService.getFirstShippableFulfillmentGroup(cart);
    if (shippableFulfillmentGroup != null) {
        shippableFulfillmentGroup.setAddress(shippingForm.getAddress());
        shippableFulfillmentGroup.setPersonalMessage(shippingForm.getPersonalMessage());
        shippableFulfillmentGroup.setDeliveryInstruction(shippingForm.getDeliveryMessage());
        FulfillmentOption fulfillmentOption = fulfillmentOptionService.readFulfillmentOptionById(shippingForm.getFulfillmentOptionId());
        shippableFulfillmentGroup.setFulfillmentOption(fulfillmentOption);
        cart = orderService.save(cart, true);
    }
    // Add module specific logic
    checkoutControllerExtensionManager.getProxy().performAdditionalShippingAction();
    if (isAjaxRequest(request)) {
        // Add module specific model variables
        checkoutControllerExtensionManager.getProxy().addAdditionalModelVariables(model);
        return getCheckoutView();
    } else {
        return getCheckoutPageRedirect();
    }
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Address(org.broadleafcommerce.profile.core.domain.Address) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) Customer(org.broadleafcommerce.profile.core.domain.Customer) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) FulfillmentOption(org.broadleafcommerce.core.order.domain.FulfillmentOption) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress)

Example 35 with Address

use of org.broadleafcommerce.profile.core.domain.Address in project BroadleafCommerce by BroadleafCommerce.

the class CheckoutFormServiceImpl method prePopulatePaymentInfoForm.

@Override
public PaymentInfoForm prePopulatePaymentInfoForm(PaymentInfoForm paymentInfoForm, ShippingInfoForm shippingInfoForm, Order cart) {
    Customer customer = CustomerState.getCustomer();
    String emailAddress = getKnownEmailAddress(cart, customer);
    paymentInfoForm.setEmailAddress(emailAddress);
    Address billingAddress = getBillingAddress(cart);
    if (billingAddress != null) {
        paymentInfoForm.setAddress(billingAddress);
    }
    CustomerPayment customerPaymentUsedForOrder = getCustomerPaymentUsedForOrder();
    Long customerPaymentId = (customerPaymentUsedForOrder == null) ? null : customerPaymentUsedForOrder.getId();
    paymentInfoForm.setCustomerPaymentId(customerPaymentId);
    boolean shouldUseCustomerPaymentDefaultValue = getShouldUseCustomerPaymentDefaultValue(customerPaymentUsedForOrder);
    paymentInfoForm.setShouldUseCustomerPayment(shouldUseCustomerPaymentDefaultValue);
    boolean shouldUseShippingAddressDefaultValue = getShouldUseShippingAddressDefaultValue(customerPaymentUsedForOrder, paymentInfoForm, shippingInfoForm);
    paymentInfoForm.setShouldUseShippingAddress(shouldUseShippingAddressDefaultValue);
    boolean shouldSaveNewPaymentDefaultValue = getShouldSaveNewPaymentDefaultValue();
    paymentInfoForm.setShouldSaveNewPayment(shouldSaveNewPaymentDefaultValue);
    return paymentInfoForm;
}
Also used : Address(org.broadleafcommerce.profile.core.domain.Address) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) Customer(org.broadleafcommerce.profile.core.domain.Customer) CustomerPayment(org.broadleafcommerce.profile.core.domain.CustomerPayment)

Aggregations

Address (org.broadleafcommerce.profile.core.domain.Address)37 FulfillmentGroup (org.broadleafcommerce.core.order.domain.FulfillmentGroup)15 Order (org.broadleafcommerce.core.order.domain.Order)15 Customer (org.broadleafcommerce.profile.core.domain.Customer)14 AddressImpl (org.broadleafcommerce.profile.core.domain.AddressImpl)11 CustomerAddress (org.broadleafcommerce.profile.core.domain.CustomerAddress)11 Transactional (org.springframework.transaction.annotation.Transactional)10 Test (org.testng.annotations.Test)10 FulfillmentGroupItem (org.broadleafcommerce.core.order.domain.FulfillmentGroupItem)9 Money (org.broadleafcommerce.common.money.Money)8 ArrayList (java.util.ArrayList)7 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)7 State (org.broadleafcommerce.profile.core.domain.State)7 StateImpl (org.broadleafcommerce.profile.core.domain.StateImpl)7 ISOCountry (org.broadleafcommerce.common.i18n.domain.ISOCountry)6 ISOCountryImpl (org.broadleafcommerce.common.i18n.domain.ISOCountryImpl)6 FulfillmentGroupImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupImpl)6 FulfillmentGroupItemImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl)6 Country (org.broadleafcommerce.profile.core.domain.Country)6 CountryImpl (org.broadleafcommerce.profile.core.domain.CountryImpl)6