Selling Per-Node Access With Drupal Commerce

This screencast builds on the previous screencast showing selling a role. This time, though, we're going to sell an individual node. Here's the recipe:

  • We have Content Access and its submodule Content Access Rules enabled
  • Create a content type called Premium Content
  • Instead of granting access to that entire content type by role, grant it on a user-by-user, node-by-node basis
  • Add a nodereference field to our product; each product that sells access to a node should have the nodereference set to the content in question.
  • Add a rule (and component)
    • When the order is updated
    • If its state is Completed
    • Loop through the line items (invoke a component)
    • If the line item has a product reference field
    • If the Product has a nodereference field
    • Grant access to the node listed in the nodereference to the user who created the order.
Posted December 16, 2011

Comments

Submitted by Brian (not verified) on

Hi Randy,
I was following along, and everything worked perfectly on my local machine! However, when I went to do this on a live site, I ran into an issue while creating the component for the loop. I don't have the field value "commerce_product" (when I compared my localhost site to my live site, I realized I was missing others as well.)

I do have:
commerce_customer_address
commerce_line_items
commerce_order_total
commerce_customer_billing
commerce_price

But I do not have:
commerce_unit_price
commerce_total
commerce_product
commerce_display_path

Any ideas on why I wouldn't have all of the options on the live site while I do on my localhost?

Thanks again Randy!

Submitted by Fossie (not verified) on

Hello,

Is it easily possible to create just one product: e.g. Buy premium content by nid?

I want to sell cv's online, those are submitted by users and if you have to programmatically add for every cv a product it will be a huge product list.

I want to show only certain information of the cv and when they buy / pay for the cv, the buyer get access to de full node information.

In short, show cv (partial)
Add button (product I suppose); Buy cv (pass nid of the cv to the product)

Add to cart, when completed the purchase, show full cv to that user.

Can you point me in the good direction?

TIA,
Fossie

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <br>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
X
In 2019 Commerce Guys rebranded to Centarro.

Change is at the center of eCommerce, but our team and mission remain the same.

Our consulting, development, and support offerings apply our expertise to help you adapt to change and grow.

Find us now at: https://www.centarro.io