Search in sources :

Example 1 with OfferTargetCriteriaXrefImpl

use of org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXrefImpl 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;
}
Also used : OfferItemCriteriaImpl(org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl) OfferTargetCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXrefImpl) Offer(org.broadleafcommerce.core.offer.domain.Offer) OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) OfferTargetCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXref)

Example 2 with OfferTargetCriteriaXrefImpl

use of org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXrefImpl 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;
}
Also used : OfferItemCriteriaImpl(org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl) OfferTargetCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXrefImpl) Offer(org.broadleafcommerce.core.offer.domain.Offer) Calendar(java.util.Calendar) OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) OfferImpl(org.broadleafcommerce.core.offer.domain.OfferImpl) OfferTargetCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXref)

Example 3 with OfferTargetCriteriaXrefImpl

use of org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXrefImpl in project BroadleafCommerce by BroadleafCommerce.

the class CreateOfferUtility method createOffer.

public Offer createOffer(String offerName, OfferType offerType, OfferDiscountType discountType, double value, String orderRule, boolean stackable, boolean combinable, int priority, String qualifierRule) {
    Offer offer = offerDao.create();
    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));
    if (stackable) {
        offer.setOfferItemTargetRuleType(OfferItemRestrictionRuleType.QUALIFIER_TARGET);
    }
    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(combinable);
    if (qualifierRule != null) {
        OfferItemCriteria qoic = new OfferItemCriteriaImpl();
        qoic.setQuantity(1);
        qoic.setMatchRule(qualifierRule);
        OfferQualifyingCriteriaXref qualifyingXref = new OfferQualifyingCriteriaXrefImpl();
        qualifyingXref.setOffer(offer);
        qualifyingXref.setOfferItemCriteria(qoic);
        offer.setQualifyingItemCriteriaXref(Collections.singleton(qualifyingXref));
        offer.setOfferItemQualifierRuleType(OfferItemRestrictionRuleType.QUALIFIER_TARGET);
    }
    offer.setPriority(priority);
    offer = offerService.save(offer);
    offer.setMaxUsesPerOrder(50);
    return offer;
}
Also used : OfferItemCriteriaImpl(org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl) OfferTargetCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXrefImpl) Offer(org.broadleafcommerce.core.offer.domain.Offer) Calendar(java.util.Calendar) OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) OfferQualifyingCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXrefImpl) OfferTargetCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXref) OfferQualifyingCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref)

Aggregations

Offer (org.broadleafcommerce.core.offer.domain.Offer)3 OfferItemCriteria (org.broadleafcommerce.core.offer.domain.OfferItemCriteria)3 OfferItemCriteriaImpl (org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl)3 OfferTargetCriteriaXref (org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXref)3 OfferTargetCriteriaXrefImpl (org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXrefImpl)3 Calendar (java.util.Calendar)2 OfferImpl (org.broadleafcommerce.core.offer.domain.OfferImpl)1 OfferQualifyingCriteriaXref (org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref)1 OfferQualifyingCriteriaXrefImpl (org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXrefImpl)1