Alright I added a custom line item order form to a node. I read that somewhere the link to the node on which the order form was used gets saved within the order, but I need the title of the node where the order form was used to place the order. Currently I added a entity reference field which uses a view to just display the title of the actual node and the user needs to select the value manually. But I want this to be automatic and hidden if possible, how could I go about it?

Actual try: I tried to setup a rule to make this possible, but I am not able to do it since I am not able to access the data of of my content node and the form at the same time. I tried it with a simple rule, a component and last but not least through the rules forms module

  • Could you link to where you read about the URL of the order form being saved automatically? It would provide useful context, that's not a behaviour I've seen before. – Clive Aug 26 '13 at 11:19
  • I am not interested in the URL! It is obvious that the URL gets saved since there is a link (in the cart summary and so on) to the node where the form was used. But I need the title of the node without any further user interaction – tobik999 Aug 26 '13 at 12:48
  • That's my point - it's not obvious at all, could you link to the documentation that makes it obvious that the link somehow gets saved to the order? In a vanilla install of Drupal Commerce it doesn't, so I'm assuming the information you're talking about is actually describing the behaviour of a custom/contrib module, or is just plain incorrect – Clive Aug 27 '13 at 10:09
  • Set up a line item, create product reference the product in a node and put the product into your basket, you will see in the cart view that product is linked to the original node the product was putted into the cart. It is also mentioned here: drupal.stackexchange.com/a/63854/17900 – tobik999 Aug 27 '13 at 10:28

I found a pretty bad solution: I added to the node template the following jquery, which really just writes the node title of the current node to a field in the line item.

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
        var title= $('#page-title').text();        
        $('#your-line-item-field-id').val(title );
        $('#your-line-item-field-id').prop('disabled', true);
| improve this answer | |

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.