It would be much more flexible if the node would be published through an action in the Rules interface instead of in the commerce_node_checkout_publish_associated_nodes callback. This way you can easily change what happens to the node; for example, you could use modules like workflow, workbench moderation, or Revisioning to put the node into a different "review" state instead of publishing the node.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

trigdog’s picture

Here is a patch for this functionality. Will have to clear your cache so rules can see the default rule changed.

trigdog’s picture

Status: Active » Needs review

changed status

Status: Needs review » Needs work

The last submitted patch, commerce_node_checkout-use_rules_to_publish_node-2085191-1.patch, failed testing.

bunnicula’s picture

I need this functionality too. thanks for the patch!

What I'm trying to do is to allow anonymous users to create a node and view their unpublished content. If they like it, they'll be invited to register and purchase a pay-to-publish product.

Is that something I can do with Rules and/or Commerce Node Checkout or do i need custom hooks?

trigdog’s picture

Commerce Node Checkout should do exactly what you want. It already supports anonymous users to create the nodes and purchase them. You can configure Commerce to have the user register when checking out. If you want them to preview it just require them to preview it through the content type(s) you have configured to your Commerce Node Checkout products. You shouldn't need my patch unless you are wanting to moderate it or do something other than publish the node once the checkout is complete; although, by default the patch still publishes the node when the checkout is complete. This way it doesn't break the current functionality. It just makes it easier to change the functionality through rules.

trigdog’s picture

Assigned: trigdog » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
mstef’s picture

Status: Needs review » Needs work

This completely changes the utility of the Rules plugin 'commerce_node_checkout_publish_associated_nodes' since it's new function would be to just extract the nodes from the order and pass them to the new Rules plugin to publish them.

I like the idea of doing what you said. Can you adjust the patch to make the necessary changes?

  • Commit 340e1f0 on 7.x-1.x by mstef:
    Use rules to publish nodes after an order. [#2085191]
    
mstef’s picture

Status: Needs work » Fixed

Thanks for your help. I wrapped up the last part I mentioned.

I'll have to remember to include instructions in the next release to make sure people update their Rules, in the case that they've overridden the Rule.

mstef’s picture

Status: Fixed » Needs work

This actually still needs work. The previous code was setting the order owner to be the node owner. Your rule is setting the list item owner to be the order owner.

  • Commit 5eae6c4 on 7.x-1.x by mstef:
    Fixed rule variable names. [#2085191]
    
mstef’s picture

Status: Needs work » Fixed

Looks like it was just the names of the set variables that were off.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.