I'm experimenting with Commerce 2 and Drupal 8.
I want to set up a flow where people can pay for a node-- use cases like classified ad listing (pay per post), event signup (pay to register), and so on.
Here's what I did so far.
- Create a content type classified ad.
- Create a product 1 month of ad exposure.
- Add an entity reference field on classified ad with the default value set to 1 month of ad exposure. Set the display widget for this field to rendered entity. Hide this field with field permissions. (This allows the user to create a classified ad node and then see an Add to cart button for the correct product after saving.)
So far, so good. But, with this configuration, the order doesn't have any information about the original node (content type: classified ad). I need to know which node the purchase/order was made for because I want to publish that node.
So, I changed the default order type: I added an entity reference to content of type classified ad. But how do I populate this entity reference field with the correct node? Or is there a better way to link the node for which the product was purchased with the order?