use of org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOptionImpl in project BroadleafCommerce by BroadleafCommerce.
the class CheckoutTest method buildFulfillmentGroup.
private FulfillmentGroup buildFulfillmentGroup(Order order, Address address) {
FulfillmentGroup group = new FulfillmentGroupImpl();
group.setIsShippingPriceTaxable(true);
group.setOrder(order);
group.setAddress(address);
List<FulfillmentGroup> groups = new ArrayList<>();
groups.add(group);
order.setFulfillmentGroups(groups);
Money total = new Money(5D);
group.setShippingPrice(total);
FixedPriceFulfillmentOption option = new FixedPriceFulfillmentOptionImpl();
option.setPrice(new Money(0));
option.setFulfillmentType(FulfillmentType.PHYSICAL_SHIP);
group.setFulfillmentOption(option);
return group;
}
use of org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOptionImpl in project BroadleafCommerce by BroadleafCommerce.
the class OfferTest method testFulfillmentGroupOffers.
@Test(groups = { "testFulfillmentGroupOffers" }, dependsOnGroups = { "testCustomerAssociatedOffers2" })
@Transactional
public void testFulfillmentGroupOffers() throws Exception {
Order order = orderService.createNewCartForCustomer(createCustomer());
FixedPriceFulfillmentOption option = new FixedPriceFulfillmentOptionImpl();
option.setPrice(new Money(0));
option.setFulfillmentType(FulfillmentType.PHYSICAL_SHIP);
order.setFulfillmentGroups(createFulfillmentGroups(option, 5D, order));
orderService.save(order, false);
order.addOrderItem(createDiscreteOrderItem(sku1, 10D, null, true, 2, order));
order.addOrderItem(createDiscreteOrderItem(sku2, 20D, null, true, 1, order));
order.addOfferCode(createOfferUtility.createOfferCode("20 Percent Off Item Offer", OfferType.FULFILLMENT_GROUP, OfferDiscountType.PERCENT_OFF, 20, null, true, true, 10));
order.addOfferCode(createOfferUtility.createOfferCode("3 Dollars Off Item Offer", OfferType.FULFILLMENT_GROUP, OfferDiscountType.AMOUNT_OFF, 3, null, true, true, 10));
List<Offer> offers = offerService.buildOfferListForOrder(order);
offerService.applyAndSaveOffersToOrder(offers, order);
offerService.applyAndSaveFulfillmentGroupOffersToOrder(offers, order);
assert (order.getFulfillmentGroups().get(0).getShippingPrice().equals(new Money(1.6D)));
}
use of org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOptionImpl in project BroadleafCommerce by BroadleafCommerce.
the class OfferTest method testBOGOAmountOffCombination.
@Test(groups = { "testPercentageOffOffer" }, dependsOnGroups = { "offerCreateSku1", "offerCreateSku2" })
@Transactional
public void testBOGOAmountOffCombination() throws Exception {
Order order = orderService.createNewCartForCustomer(createCustomer());
FixedPriceFulfillmentOption option = new FixedPriceFulfillmentOptionImpl();
option.setPrice(new Money(0));
orderService.save(order, false);
order.addOrderItem(createDiscreteOrderItem(sku1, 1000D, null, true, 1, order));
order.addOrderItem(createDiscreteOrderItem(sku2, 100D, null, true, 2, order));
order.addOfferCode(createOfferUtility.createOfferCode("10 Percent Off All Item Offer", OfferType.ORDER_ITEM, OfferDiscountType.PERCENT_OFF, 10, null, false, true, 10));
order.addOfferCode(createOfferUtility.createOfferCode("NONAME", "30 Amount Off Second Item Sku2 Offer", OfferType.ORDER_ITEM, OfferDiscountType.AMOUNT_OFF, 30, "discreteOrderItem.sku.id == " + sku2, false, true, 10, "discreteOrderItem.sku.id == " + sku2));
List<Offer> offers = offerService.buildOfferListForOrder(order);
offerService.applyAndSaveOffersToOrder(offers, order);
assert (order.getSubTotal().equals(new Money(1070D)));
}
use of org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOptionImpl in project BroadleafCommerce by BroadleafCommerce.
the class OfferTest method testThreePercentOffOffers.
@Test(groups = { "testPercentageOffOffer" }, dependsOnGroups = { "offerCreateSku1", "offerCreateSku2" })
@Transactional
public void testThreePercentOffOffers() throws Exception {
Order order = orderService.createNewCartForCustomer(createCustomer());
FixedPriceFulfillmentOption option = new FixedPriceFulfillmentOptionImpl();
option.setPrice(new Money(0));
orderService.save(order, false);
order.addOrderItem(createDiscreteOrderItem(sku1, 4.99D, null, true, 1, order));
order.addOrderItem(createDiscreteOrderItem(sku2, 9.99D, null, true, 1, order));
order.addOfferCode(createOfferUtility.createOfferCode("60 Percent Off Item Sku1 Offer", OfferType.ORDER_ITEM, OfferDiscountType.PERCENT_OFF, 60, "discreteOrderItem.sku.id == " + sku1, false, true, 10));
order.addOfferCode(createOfferUtility.createOfferCode("60 Percent Off Item Sku2 Offer", OfferType.ORDER_ITEM, OfferDiscountType.PERCENT_OFF, 60, "discreteOrderItem.sku.id == " + sku2, false, true, 10));
order.addOfferCode(createOfferUtility.createOfferCode("40 Percent Off All Item Offer", OfferType.ORDER_ITEM, OfferDiscountType.PERCENT_OFF, 40, null, false, true, 10));
List<Offer> offers = offerService.buildOfferListForOrder(order);
offerService.applyAndSaveOffersToOrder(offers, order);
assert (order.getSubTotal().equals(new Money(6D)));
}
use of org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOptionImpl in project BroadleafCommerce by BroadleafCommerce.
the class FulfillmentGroupDataProvider method provideBasicSalesFulfillmentGroup.
@DataProvider(name = "basicFulfillmentGroup")
public static Object[][] provideBasicSalesFulfillmentGroup() {
FulfillmentGroupImpl sos = new FulfillmentGroupImpl();
sos.setReferenceNumber("123456789");
FixedPriceFulfillmentOption option = new FixedPriceFulfillmentOptionImpl();
option.setPrice(new Money(0));
sos.setFulfillmentOption(option);
return new Object[][] { { sos } };
}
Aggregations