use of org.broadleafcommerce.core.order.domain.OrderAttribute in project BroadleafCommerce by BroadleafCommerce.
the class DefaultCurrentOrderPaymentRequestService method addOrderAttributeToOrder.
@Override
public void addOrderAttributeToOrder(Long orderId, String orderAttributeKey, String orderAttributeValue) throws PaymentException {
Order currentCart = CartState.getCart();
Long currentCartId = currentCart.getId();
if (orderId != null && !currentCartId.equals(orderId)) {
logWarningIfCartMismatch(currentCartId, orderId);
currentCart = orderService.findOrderById(orderId);
}
OrderAttribute orderAttribute = new OrderAttributeImpl();
orderAttribute.setName(orderAttributeKey);
orderAttribute.setValue(orderAttributeValue);
orderAttribute.setOrder(currentCart);
currentCart.getOrderAttributes().put(orderAttributeKey, orderAttribute);
try {
orderService.save(currentCart, false);
} catch (PricingException e) {
throw new PaymentException(e);
}
}
Aggregations