Search in sources :

Example 6 with FulfillmentOption

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

the class BandedPriceFulfillmentTest method calculationResponse.

protected Money calculationResponse(FulfillmentOption option, Order order) throws Exception {
    Set<FulfillmentOption> options = new HashSet<FulfillmentOption>();
    options.add(option);
    BandedFulfillmentPricingProvider provider = new BandedFulfillmentPricingProvider();
    return provider.estimateCostForFulfillmentGroup(order.getFulfillmentGroups().get(0), options).getFulfillmentOptionPrices().get(option);
}
Also used : BandedFulfillmentPricingProvider(org.broadleafcommerce.core.pricing.service.fulfillment.provider.BandedFulfillmentPricingProvider) BandedPriceFulfillmentOption(org.broadleafcommerce.core.order.fulfillment.domain.BandedPriceFulfillmentOption) BandedWeightFulfillmentOption(org.broadleafcommerce.core.order.fulfillment.domain.BandedWeightFulfillmentOption) FulfillmentOption(org.broadleafcommerce.core.order.domain.FulfillmentOption) HashSet(java.util.HashSet)

Example 7 with FulfillmentOption

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

the class FixedPriceFulfillmentTest method testNullFulfillmentOptionInEstimation.

public void testNullFulfillmentOptionInEstimation() throws Exception {
    Set<FulfillmentOption> options = new HashSet<FulfillmentOption>();
    FixedPriceFulfillmentOption option1 = new FixedPriceFulfillmentOptionImpl();
    option1.setPrice(new Money(BigDecimal.ONE));
    FixedPriceFulfillmentOption option2 = new FixedPriceFulfillmentOptionImpl();
    option2.setPrice(new Money(BigDecimal.TEN));
    options.add(option1);
    options.add(option2);
    FixedPriceFulfillmentPricingProvider provider = new FixedPriceFulfillmentPricingProvider();
    FulfillmentGroup fg = new FulfillmentGroupImpl();
    FulfillmentEstimationResponse response = provider.estimateCostForFulfillmentGroup(fg, options);
    for (Entry<? extends FulfillmentOption, Money> entry : response.getFulfillmentOptionPrices().entrySet()) {
        assertEquals(((FixedPriceFulfillmentOption) entry.getKey()).getPrice(), entry.getValue());
    }
}
Also used : FixedPriceFulfillmentPricingProvider(org.broadleafcommerce.core.pricing.service.fulfillment.provider.FixedPriceFulfillmentPricingProvider) Money(org.broadleafcommerce.common.money.Money) FulfillmentGroupImpl(org.broadleafcommerce.core.order.domain.FulfillmentGroupImpl) FixedPriceFulfillmentOption(org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOption) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) FulfillmentEstimationResponse(org.broadleafcommerce.core.pricing.service.fulfillment.provider.FulfillmentEstimationResponse) FixedPriceFulfillmentOption(org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOption) FulfillmentOption(org.broadleafcommerce.core.order.domain.FulfillmentOption) FixedPriceFulfillmentOptionImpl(org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOptionImpl) HashSet(java.util.HashSet)

Example 8 with FulfillmentOption

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

the class FulfillmentVariableExpression method getFulfillmentEstimateResponse.

public FulfillmentEstimationResponse getFulfillmentEstimateResponse() {
    Order cart = CartState.getCart();
    if (!isNullOrder(cart) && cart.getFulfillmentGroups().size() > 0 && cartStateService.cartHasPopulatedShippingAddress()) {
        try {
            List<FulfillmentOption> fulfillmentOptions = fulfillmentOptionService.readAllFulfillmentOptions();
            FulfillmentGroup firstShippableFulfillmentGroup = fulfillmentGroupService.getFirstShippableFulfillmentGroup(cart);
            return fulfillmentPricingService.estimateCostForFulfillmentGroup(firstShippableFulfillmentGroup, new HashSet<>(fulfillmentOptions));
        } catch (FulfillmentPriceException e) {
        // do nothing
        }
    }
    return null;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) FulfillmentPriceException(org.broadleafcommerce.common.vendor.service.exception.FulfillmentPriceException) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) FulfillmentOption(org.broadleafcommerce.core.order.domain.FulfillmentOption)

Example 9 with FulfillmentOption

use of org.broadleafcommerce.core.order.domain.FulfillmentOption 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 10 with FulfillmentOption

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

the class CheckoutFormServiceImpl method prePopulateShippingInfoForm.

@Override
public ShippingInfoForm prePopulateShippingInfoForm(ShippingInfoForm shippingInfoForm, Order cart) {
    FulfillmentGroup firstShippableFulfillmentGroup = fulfillmentGroupService.getFirstShippableFulfillmentGroup(cart);
    if (firstShippableFulfillmentGroup != null) {
        // if the cart has already has fulfillment information
        if (firstShippableFulfillmentGroup.getAddress() != null) {
            shippingInfoForm.setAddress(firstShippableFulfillmentGroup.getAddress());
        } else {
            // check for a default address for the customer
            CustomerAddress defaultAddress = customerAddressService.findDefaultCustomerAddress(CustomerState.getCustomer().getId());
            if (defaultAddress != null) {
                shippingInfoForm.setAddress(defaultAddress.getAddress());
                shippingInfoForm.setAddressName(defaultAddress.getAddressName());
            }
        }
        FulfillmentOption fulfillmentOption = firstShippableFulfillmentGroup.getFulfillmentOption();
        if (fulfillmentOption != null) {
            shippingInfoForm.setFulfillmentOption(fulfillmentOption);
            shippingInfoForm.setFulfillmentOptionId(fulfillmentOption.getId());
        }
    }
    return shippingInfoForm;
}
Also used : FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) FulfillmentOption(org.broadleafcommerce.core.order.domain.FulfillmentOption) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress)

Aggregations

FulfillmentOption (org.broadleafcommerce.core.order.domain.FulfillmentOption)10 HashMap (java.util.HashMap)4 Money (org.broadleafcommerce.common.money.Money)4 FulfillmentGroup (org.broadleafcommerce.core.order.domain.FulfillmentGroup)4 HashSet (java.util.HashSet)3 FulfillmentPriceException (org.broadleafcommerce.common.vendor.service.exception.FulfillmentPriceException)3 Order (org.broadleafcommerce.core.order.domain.Order)3 FulfillmentEstimationResponse (org.broadleafcommerce.core.pricing.service.fulfillment.provider.FulfillmentEstimationResponse)3 BigDecimal (java.math.BigDecimal)2 BandedPriceFulfillmentOption (org.broadleafcommerce.core.order.fulfillment.domain.BandedPriceFulfillmentOption)2 BandedWeightFulfillmentOption (org.broadleafcommerce.core.order.fulfillment.domain.BandedWeightFulfillmentOption)2 FixedPriceFulfillmentOption (org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOption)2 CustomerAddress (org.broadleafcommerce.profile.core.domain.CustomerAddress)2 Map (java.util.Map)1 MultiValueMap (org.apache.commons.collections.map.MultiValueMap)1 ClonePolicyCollectionOverride (org.broadleafcommerce.common.extensibility.jpa.clone.ClonePolicyCollectionOverride)1 AdminPresentationMap (org.broadleafcommerce.common.presentation.AdminPresentationMap)1 Sku (org.broadleafcommerce.core.catalog.domain.Sku)1 BundleOrderItem (org.broadleafcommerce.core.order.domain.BundleOrderItem)1 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)1