Drupal Commerce Blog

What's happening in the world of Drupal Commerce.

Selling Organic Groups using Drupal Commerce

I don't know about you guys, but I like to hang out in the Question & Answer section of drupalcommerce.org. Lots of great people in there sharing knowledge and upvoting the hardest questions. Today, I wanted to highlight a particularly great question.

Read the featured Q&A

In summary, Mike wants to know "How to subscribe customer to an Organic Group?" The answer is simple, you can do this using rules and about 10 minutes of clicking around. So I created a quick walkthrough and have given the step-by-steps below the video.


1) Create an Organic Group content type

2) Add a product reference field to the Organic Group

3) Create a new product

4) Create a new Organic Group that references the new product

5) Enable the Organic Group rule "OG member subscribe (Active)"

6) Create a rule based on the event "After an Order is first paid in full" (Exported rule here)

7) Add a loop on the Commerce Order's line items.

8) Create a component that checks the line item's commerce_product field and returns a product display. (Exported rule here)

9) Add that component as an action to the loop of the first rule you created.

10) Create a component that checks the product display to see if it's an organic group. (Exported rule here)

11) Add an action "Set user to be a member of group" to that final component

12) Add that final component as an action to the loop of the first rule you created.

13) Profit!

Image icon selling_organic_groups.png109.62 KB
Josh Miller
Posted: Nov 15, 2013


smichel on November 15, 2013

Thanks, this a big help. I'm just getting into Drupal Commerce, and will need to be selling memberships as well as the ability to post x number of nodes pretty soon. December is Drupal Commerce month for me!

S1L on November 19, 2013

Awesome step-by-step video tutorial Josh!

@smichel You'll probably won't regret making December a Drupal Commerce month: it's absolutely awesome.
Limiting nodes can be done with the node_limit module, I hope it fits your needs.
Another more complex way would be to give the user a certain amount of Userpoints (with Userpoints module) and subtract a point at every node creation (by configuring Rules)
My advice: keep it as simple as possible.

To add a bit to the Organic Group tutorial:

A Note for cases with anonymous checkout enabled:
To my knowledge (correct me if I'm wrong) using the Rule Event 'After an Order is first paid in full' together with Organic Group subscription doesn't work with 'anonymous checkout' as in that case the new user is created AFTER it's being assigned to an organic group. (the 'new user creation Rule' executes at the Event 'Completing the checkout process')
If I remember correctly that was the reason we used the Event 'Completing the checkout process' and a Condition to check if they paid in full (Order balance comparison <= 0).

And I needed to adjust the weight of the Rules so the Rule to subscribe the member to the Organic Group would be executed after the Rule that creates the member.

And another thing to think about that may be important when Selling Organic Groups:
In our case we wanted to be able to give people access to multiple Organic Groups when buying 1 product.
For example if you wanted to:
sell Organic Group 1 for 10 USD (as product 1)
sell Organic Group 2 for 20 USD (as product 2)
sell Organic Group 1 AND 2 together for 25 USD (as product 3)
Or for when you put 'bonus content' in an Organic Group and want to give that away with every Organic Group they purchase.
Something similar can be done with the implementation Josh describes and pricing Rules and automatically adding certain products to the cart when certain others are added.
It can be more complex, but doesn't have to be.

More about that in my Selling Organic Group tutorial at http://s1l.org/selling-access-organic-groups-drupal-commerce
The solution is a bit different from the solution presented by Josh as it meets a bit of a different need.

And you might want to have a look at the maximum quantity of a certain product in the cart. You probably want them to be able to purchase just 1 of every Organic Group.
Richard Jones made a tutorial that may help with that here http://www.youtube.com/watch?v=HkplhIhCSu8

Oops, I almost wrote an entire blogpost in a comment :D
Happy Drupalling!

nitvirus on December 2, 2013

I was implementing the same for a site but encountered a
"The data type of the configured argument does not match the parameter's value requirement." error during 1st component creation.
I had put

Data selector *

Also when I import the component the PROPETY: VALUE gets NODE ID to be selected automatically.

Is there something wrong.

dutchyoda on January 14, 2014

I've got the same issue. I have a taxonomy term as product display (not my choice). I followed the steps altering Node by Taxonomy term, but now I'm stuck creating the action in the Step1-compontent.