Search in sources :

Example 1 with OrderInfoForm

use of org.broadleafcommerce.core.web.checkout.model.OrderInfoForm in project BroadleafCommerce by BroadleafCommerce.

the class OrderInfoFormValidator method validate.

public void validate(Object obj, Errors errors) {
    OrderInfoForm orderInfoForm = (OrderInfoForm) obj;
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "emailAddress", "emailAddress.required");
    if (!errors.hasErrors()) {
        if (!EmailValidator.getInstance().isValid(orderInfoForm.getEmailAddress())) {
            errors.rejectValue("emailAddress", "emailAddress.invalid", null, null);
        }
    }
}
Also used : OrderInfoForm(org.broadleafcommerce.core.web.checkout.model.OrderInfoForm)

Example 2 with OrderInfoForm

use of org.broadleafcommerce.core.web.checkout.model.OrderInfoForm in project BroadleafCommerce by BroadleafCommerce.

the class OnePageCheckoutProcessor method populateModelVariables.

@Override
public Map<String, Object> populateModelVariables(String tagName, Map<String, String> tagAttributes, BroadleafTemplateContext context) {
    // Pre-populate the command objects
    OrderInfoForm orderInfoForm = context.parseExpression(tagAttributes.get("orderInfoForm"));
    ShippingInfoForm shippingInfoForm = context.parseExpression(tagAttributes.get("shippingInfoForm"));
    BillingInfoForm billingInfoForm = context.parseExpression(tagAttributes.get("billingInfoForm"));
    String orderInfoHelpMessage = context.parseExpression(tagAttributes.get("orderInfoHelpMessage"));
    String billingInfoHelpMessage = context.parseExpression(tagAttributes.get("billingInfoHelpMessage"));
    String shippingInfoHelpMessage = context.parseExpression(tagAttributes.get("shippingInfoHelpMessage"));
    prepopulateCheckoutForms(CartState.getCart(), orderInfoForm, shippingInfoForm, billingInfoForm);
    // Add PaymentRequestDTO to the model in the case of errors or other cases
    Map<String, Object> newModelVars = new HashMap<>();
    Order cart = CartState.getCart();
    if (cart != null && !(cart instanceof NullOrderImpl)) {
        newModelVars.put("paymentRequestDTO", orderToPaymentRequestDTOService.translateOrder(cart));
    }
    // Initialize Fulfillment Group Vars
    int numShippableFulfillmentGroups = calculateNumShippableFulfillmentGroups();
    newModelVars.put("numShippableFulfillmentGroups", numShippableFulfillmentGroups);
    populateFulfillmentOptionsAndEstimationOnModel(newModelVars);
    // Initialize View States
    newModelVars.put("orderInfoHelpMessage", orderInfoHelpMessage);
    newModelVars.put("billingInfoHelpMessage", billingInfoHelpMessage);
    newModelVars.put("shippingInfoHelpMessage", shippingInfoHelpMessage);
    populateSectionViewStates(newModelVars);
    // Helpful lists to populate dropdowns on a checkout page
    newModelVars.put("states", stateService.findStates());
    newModelVars.put("countries", countryService.findCountries());
    newModelVars.put("expirationMonths", populateExpirationMonths());
    newModelVars.put("expirationYears", populateExpirationYears());
    // Populate any Payment Processing Errors
    populateProcessingError(newModelVars);
    return newModelVars;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) OrderInfoForm(org.broadleafcommerce.core.web.checkout.model.OrderInfoForm) ShippingInfoForm(org.broadleafcommerce.core.web.checkout.model.ShippingInfoForm) HashMap(java.util.HashMap) BillingInfoForm(org.broadleafcommerce.core.web.checkout.model.BillingInfoForm) NullOrderImpl(org.broadleafcommerce.core.order.domain.NullOrderImpl)

Aggregations

OrderInfoForm (org.broadleafcommerce.core.web.checkout.model.OrderInfoForm)2 HashMap (java.util.HashMap)1 NullOrderImpl (org.broadleafcommerce.core.order.domain.NullOrderImpl)1 Order (org.broadleafcommerce.core.order.domain.Order)1 BillingInfoForm (org.broadleafcommerce.core.web.checkout.model.BillingInfoForm)1 ShippingInfoForm (org.broadleafcommerce.core.web.checkout.model.ShippingInfoForm)1