Postby ArloL » Wed Jun 04, 2014 5:06 am
Thanks prabhat.kataria. I had already looked there but didn't find something helpful.
Nonetheless I found a solution:
I extended OnePageCheckoutProcessor to include another CheckoutSectionViewType. Add a VehicleInfoForm holding the values for the new form and added a partial in templates/checkout/partials/vehicleInfoForm.html. This I also included in checkout.html. I had to add a @ModelAttribute("vehicleInfoForm") VehicleInfoForm vehicleInfoForm to all methods where the other forms where parameters in CheckoutController and BillingInfoController. Make sure it's not the last parameter.
I then added another method to CheckoutController:
@RequestMapping(
value = "/checkout/savevehicle",
method = RequestMethod.POST)
public String saveVehicleDetails(
HttpServletRequest request,
Model model,
@ModelAttribute("shippingInfoForm") ShippingInfoForm shippingForm,
@ModelAttribute("billingInfoForm") BillingInfoForm billingForm,
@ModelAttribute("giftCardInfoForm") GiftCardInfoForm giftCardInfoForm,
@ModelAttribute("orderInfoForm") OrderInfoForm orderInfoForm,
@ModelAttribute("vehicleInfoForm") VehicleInfoForm vehicleInfoForm,
BindingResult result) throws ServiceException {
Order cart = CartState.getCart();
vehicleInfoFormValidator.validate(vehicleInfoForm, result);
if (result.hasErrors()) {
return getCheckoutView();
}
OrderAttribute vehicleIdentification =
getOrderAttribute(cart, "vehicleIdentification");
OrderAttribute numberPlate = getOrderAttribute(cart, "numberPlate");
try {
vehicleIdentification.setValue(vehicleInfoForm
.getVehicleIdentification());
numberPlate.setValue(vehicleInfoForm.getNumberPlate());
orderService.save(cart, false);
} catch (PricingException pe) {
LOG.error(
"Error when saving the vehicle identification for order confirmation to the cart",
pe);
}
return getCheckoutPageRedirect();
}