Adding products on the fly to order

102 Views Asked by At

I would like to add products to cart on the fly. This means the products to add are not stored in the database and doesn't have to. But when I take a look into the cart endpoint how items added to an order the class org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO requires a product id.

So this means I've to override blCatalogService which would allow temporary products too? Is this all or did I forget something else to achieve the adding of products to the cart/order on the fly?

1

There are 1 best solutions below

0
On BEST ANSWER

The OrderItem data model and services don't strictly require a SKU but many of the out of box examples do.

You should be able to override the CartEndpoint and instead of creating an OrderItemRequestDTO, create a NonDiscreteOrderItemRequestDTO.

The AddOrderItemActivity which is part of the workflow executed when an item is added checks for this type and will create an OrderItem instead of a DiscreteOrderItem or BundleOrderItem (both of which require a SKU).

Hope this helps,

Brian

Note : I work for Broadleaf