Search in sources :

Example 1 with OrderAttributeImpl

use of org.broadleafcommerce.core.order.domain.OrderAttributeImpl 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);
    }
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) PaymentException(org.broadleafcommerce.common.vendor.service.exception.PaymentException) PricingException(org.broadleafcommerce.core.pricing.service.exception.PricingException) OrderAttribute(org.broadleafcommerce.core.order.domain.OrderAttribute) OrderAttributeImpl(org.broadleafcommerce.core.order.domain.OrderAttributeImpl)

Aggregations

PaymentException (org.broadleafcommerce.common.vendor.service.exception.PaymentException)1 Order (org.broadleafcommerce.core.order.domain.Order)1 OrderAttribute (org.broadleafcommerce.core.order.domain.OrderAttribute)1 OrderAttributeImpl (org.broadleafcommerce.core.order.domain.OrderAttributeImpl)1 PricingException (org.broadleafcommerce.core.pricing.service.exception.PricingException)1