1
Answers
Vote up!
0
Vote down!

How to use rules to create content from line_items lineitems on payment

My project is to generate content (nodes) based on the selected line items when payment completes.

So basically a rule triggered by the payment received which would scan the order by lineitem looking for selected SKUs, and on detecting eligible SKUs generate a node. (My customers are buying a type of ticket in bundles of 1 three and six, so look for ticket sales and then generate the tickets).

Any advice, pointers, examples will be gratefully received.

Asked by: pxs
on June 20, 2013

1 Answer

Vote up!
0
Vote down!

Simple rule :D

1) You'll want to use the event (under Payment) "Commerce Payment Order Paid in Full"

http://pastebin.com/SH7dhN4k

- Add a "fetch entity by property" to bring in all the line items
- Add an action to call the following component (a rule without an event)

2) Create a component with a line item as a parameter+provided

http://pastebin.com/S4xNTx8s

- Check to make sure it's a product line item (taxes and shipping are also line items)
- Confirm line item has a "commerce product" field, so you have access to all the product data you could want (if you have a custom field you want access to, you'll want to an "entity has field" on the product attached to the line item)
- (optional) pull the Display Node into it ... so you can have product display info.
- Create a node entity
- Save node entity

Josh Miller
Answer by: Josh Miller
Posted: Jun 20, 2013