title: How to generate multiple orders from cart in Hybris storefront?
body: <p>I'm working with Hybris 6.3 we generated a module for a B2B implementation  and I have the requirement of splitting the cart contents into different orders depending on the products in the cart, the billing address, payment, delivery, etc must share the same parameters.</p>
  
  <p>From the requirements we've gathered from our client, we concluded applying consignments strategies aren't what we requiere here, since that handles one order and splits it for shipping and delivery purposes, instead our client's needs are that the different products in the cart to be grouped by a set of shared attributes and generate an order for each group of products.</p>
  
  <p>So far I have identified the class in charge of placing the order in the storefront extension, <strong>DefaultCheckoutFacade</strong>, which contains the following method:</p>
  
  <pre><code> @Override
   public OrderData placeOrder() throws InvalidCartException
   {
       final CartModel cartModel = getCart();
       if (cartModel != null)
       {
           if (cartModel.getUser().equals(getCurrentUserForCheckout()) || getCheckoutCustomerStrategy().isAnonymousCheckout())
           {
               beforePlaceOrder(cartModel);
               final OrderModel orderModel = placeOrder(cartModel);
               afterPlaceOrder(cartModel, orderModel);
               if (orderModel != null)
               {
                   return getOrderConverter().convert(orderModel);
               }
           }
       }
       return null;
   }
  </code></pre>
  
  <p>From what I understand, I should override this method to generate a different <strong>CartModel</strong> accordingly to the criteria set in my requirements and place an order for each <strong>CartModel</strong>. I revised the <strong>CartModel</strong> class, and it's superclass <strong>AbstractOrderModel</strong>, I'm guessing after the <em>getCart()</em> call in the method above, I just need to modify the entries in the <strong>CartModel</strong> and make a call to the method <em>placeOrder()</em> for each order I need to place, but is it allowed to modify the <strong>CartModel</strong> object in this way? </p>
  
  <p>Or if I need to split my cart into different orders, should I approach this in a different way? Is something like having multiple carts but showing them as one something that should be done? Does this kind of modification should be done on the OOTB commercefacades extension? Is there a way to extend it somewhere in our module?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I started to read about <a href="https://help.hybris.com/6.2.0/hcd/4d094e78a5494963b2d66148167f0553.html" rel="nofollow noreferrer">Multiple Carts</a> and it seems to be what I need, but I haven't found how to save entries to a saved cart. In <a href="https://help.hybris.com/6.2.0/hcd/8b85a20586691014bacda05068f9c842.html" rel="nofollow noreferrer">this link</a> I can see how to save the cart, the method <em>saveCart</em> returns a <strong>CommerceSaveCartResultData</strong> object, both <em>saveCart</em> and the method <em>getCartForCodeAndCurrentUser</em> receive a <strong>CommerceSaveCartParameter</strong> which must contain a CartModel, how can I generate an instance of this object to set in a <strong>CommerceSaveCartParameter</strong>?</p>