I have a requirement to be able to link a line item to another line item. For this example imagine line item A = Washing machine and line Item B is a warranty for said line item A.
I have managed to do this using a custom metafield but when it comes to creating the publish order I need to mirror the relationships within the PO as the out of the box SaveToPurchaseOrder does not look at custom metafields.
Q: Is there anything out of the box, which I can use within the cart object to link these line items in a parent->child hirarchy and, which will be copied over to the purchase order when its created?
Update (my response from prevuous post - how I got it working but dont like it):
Q: How did you like them, did you create a metafield on the line item class?
A: Correct, I had to also add the same metafield to the purchase order. and then go through some tree re-creation algorithm to create the hirarchy. Imagine the trunk is the cart, the main braches are the immediate lineItems, then the smaller branches off them are the child lineItems. Looping round the cart this way allows me to re-create the hirarchy in the purchase order. (Edit here: Way to match is to match the Code and the quantity(of the parent), link the child in the PO and then record the child is linked, so as not to link again)
I cannot believe EPiServer has nothing out of the box to faciliate child line items related to a parent? If it does not its missing things like adding services, warranties and sub -upsell items, which need to relate to the parent item.
Sorry re-read your reply. Custom metafields (in my experience, do not get carried over to the purchase order upon out of the box creation. It needs to be set manually when you have got the cart and purchase order available at the same time.