use of org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl in project BroadleafCommerce by BroadleafCommerce.
the class OfferDataItemProvider method createItemBasedOfferWithItemCriteria.
public List<Offer> createItemBasedOfferWithItemCriteria(String orderRule, OfferDiscountType discountType, String qualRule, String targetRule) {
List<Offer> offers = createItemBasedOffer(orderRule, targetRule, discountType);
if (qualRule != null) {
Offer firstOffer = offers.get(0);
OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
// qualCriteria.setQualifyingOffer(offers.get(0));
qualCriteria.setQuantity(1);
qualCriteria.setMatchRule(qualRule);
Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
xref.setOffer(firstOffer);
xref.setOfferItemCriteria(qualCriteria);
criterias.add(xref);
firstOffer.setQualifyingItemCriteriaXref(criterias);
}
return offers;
}
use of org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl in project BroadleafCommerce by BroadleafCommerce.
the class OfferDataItemProvider method createOrderBasedOfferWithItemCriteria.
public List<Offer> createOrderBasedOfferWithItemCriteria(String orderRule, OfferDiscountType discountType, String orderItemMatchRule) {
List<Offer> offers = createOrderBasedOffer(orderRule, discountType);
Offer firstOffer = offers.get(0);
OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
// qualCriteria.setQualifyingOffer(offers.get(0));
qualCriteria.setQuantity(1);
qualCriteria.setMatchRule(orderItemMatchRule);
Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
xref.setOffer(firstOffer);
xref.setOfferItemCriteria(qualCriteria);
criterias.add(xref);
firstOffer.setQualifyingItemCriteriaXref(criterias);
return offers;
}
use of org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl in project BroadleafCommerce by BroadleafCommerce.
the class OfferDataItemProvider method createFGBasedOfferWithItemCriteria.
public List<Offer> createFGBasedOfferWithItemCriteria(String orderRule, String fgRule, OfferDiscountType discountType, String orderItemMatchRule) {
List<Offer> offers = createFGBasedOffer(orderRule, fgRule, discountType);
Offer firstOffer = offers.get(0);
OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
qualCriteria.setQuantity(1);
qualCriteria.setMatchRule(orderItemMatchRule);
Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
xref.setOffer(firstOffer);
xref.setOfferItemCriteria(qualCriteria);
criterias.add(xref);
firstOffer.setQualifyingItemCriteriaXref(criterias);
return offers;
}
use of org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl in project BroadleafCommerce by BroadleafCommerce.
the class OfferDataItemProvider method createItemBasedOffer.
public List<Offer> createItemBasedOffer(String orderRule, String targetRule, OfferDiscountType discountType) {
List<Offer> offers = createOrderBasedOffer(orderRule, discountType);
offers.get(0).setType(OfferType.ORDER_ITEM);
if (targetRule != null) {
Offer offer = offers.get(0);
OfferItemCriteria targetCriteria = new OfferItemCriteriaImpl();
// targetCriteria.setQualifyingOffer(offers.get(0));
targetCriteria.setQuantity(1);
targetCriteria.setMatchRule(targetRule);
OfferTargetCriteriaXref targetXref = new OfferTargetCriteriaXrefImpl();
targetXref.setOffer(offer);
targetXref.setOfferItemCriteria(targetCriteria);
offer.setTargetItemCriteriaXref(Collections.singleton(targetXref));
}
return offers;
}
use of org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl in project BroadleafCommerce by BroadleafCommerce.
the class PricingTest method createOffer.
private Offer createOffer(String offerName, OfferType offerType, OfferDiscountType discountType, double value, String customerRule, String orderRule) {
Offer offer = new OfferImpl();
offer.setName(offerName);
offer.setStartDate(SystemTime.asDate());
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -1);
offer.setStartDate(calendar.getTime());
calendar.add(Calendar.DATE, 2);
offer.setEndDate(calendar.getTime());
offer.setType(offerType);
offer.setDiscountType(discountType);
offer.setValue(BigDecimal.valueOf(value));
offer.setAutomaticallyAdded(true);
OfferItemCriteria oic = new OfferItemCriteriaImpl();
oic.setQuantity(1);
oic.setMatchRule(orderRule);
OfferTargetCriteriaXref targetXref = new OfferTargetCriteriaXrefImpl();
targetXref.setOffer(offer);
targetXref.setOfferItemCriteria(oic);
offer.setTargetItemCriteriaXref(Collections.singleton(targetXref));
offer.setCombinableWithOtherOffers(true);
offer = offerService.save(offer);
offer.setMaxUsesPerOrder(50);
return offer;
}
Aggregations