1

I want use drupal commerce's line items in the following case.

  1. I have 3 Products. (Product A, Product B, Product C).
  2. I want to add line items to these 3 different products. So Product A will have the following structure. Product A -> Line Item A-1, Line Item A-2 Product B will have the structure as , Product B -> Line Item B-1, Line Item B-2

Now, This is okay with me. But if I want to add line items to the first level of line items. How can it be possible ?

The case is, If I want to add 2 Line items to Line Item A-1. So the Product A will have a final structure as,

                              Product A
                      ___________|____________
                     |                       |
                Line Item A-1           Line Item A-2
          ___________|____________
         |                       |
     Child Line Item A-1(i)   Child Line Item A-1(ii)

I hope I am able to tell you my problem. Please help me on this.

3

Judging from your question you seem very confused about line items and what they are used for.

Line items are used to link products to an order. The whole idea is that some data you want to fetch from the product directly, like it's title, media etc, while some data you need to copy, like the price and sometimes you need to add data, like the address for a subscription and quantity.

The reason you need to copy the price, is that if you ever change the price of the product you want to preserve the old orders which is why you need to store the price for each purchase.

There is nothing technical that will hinder you to create a relationship from products to line items or from line items to line items, but it won't make much sense to do so, and will most likely result in some strange bugs, as line items are used for orders to store info about products, and commerce expects this.

  • Actually I am very new to Drupal Commerce. So I may have been mistaken. But one thing, I have created a line item and how can I associate it with a new Product. Can you please help me on that ? – Aneek Mukhopadhyay Jan 25 '12 at 6:55
  • 2
    @AneekMukhopadhyay Unless you know what you are doing, you shouldn't be messing with line items. Let Commerce handle those. Line items react different depending on what state their in, which can be very confusing unless you know the whole mechanic. Doing this will most likely get you confused and not help you anywhere. You should probably ask a new question and formulate what you want to achieve and see if you can get some help. My hunch is, that you're doing it wrong. – googletorp Jan 25 '12 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.