Project:UC Node Checkout
Version:6.x-2.0-beta3
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

In 5.x, I could use workflow-ng to publish a node after a person checks out.

I started looking at this in 6.x, and am having difficulty finding the best way to do this, and was not able to find any documentation on it.

workflow-ng is replaced by Rules http://drupal.org/project/rules
Is the UC integrated with the Rules module? I noticed there is Conditional Actions in UC, but there is no way to publish a node, or to execute custom PHP code.

Is this possible yet, and if so, how do I do about configuring this?

Comments

#1

I would suggest something like the following, as I have this working fine right now:

<?php
function my_module_order($op, $arg1, $arg2) {
    if (
$op == 'update' && $arg2 == "payment_received") {   
        foreach (
$arg1->products as $product) {
           
$node_id = $product->data['node_checkout_nid'];
           
           
$node = node_load($node_id);
           
$node->status = 1; // publish the node       
           
node_save($node);
        }
    }
}
?>

Anyone see any problems with this?

#2

It worked for me without Revision Moderation enabled, but I also need this module, so I had to go around node_save.

<?php
/**
* Implementation of hook_order()
*/
function mymodule_order($op, $arg1, $arg2) {
   
//Because we also use Revision Moderation we have to do directly to the DB and not use node_save().
   
if ($op == 'update' && $arg2 == "payment_received") {    
        foreach (
$arg1->products as $product) {
           
$node_id = $product->data['node_checkout_nid'];
           
//Publish the node
           
db_query("UPDATE {node} SET status = %d WHERE nid = %d", 1, $node_id);
        }
    }
}
?>

#3

Status:active» fixed

There seems to be a module in the works that takes care of this issue:

http://drupal.org/project/uc_node_published

#4

Status:fixed» closed (fixed)

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

#5

UC Node Published doesn't seem to be working and appears abandoned. Does a anyone else have ideas for this?

#6

Using Ubercart's Conditional Actions at /admin/store/ca , I was able to get the node to publish after sucessful checkout. Here's how:

1. Add a new predicate and give it a descriptive name
2. Make sure Trigger is set to "Customer completes checkout"
3. Add an action to "Execute custom PHP code"

Here's the code:

foreach ($order->products as $product) {
            $node_id = $product->data['node_checkout_nid'];
            $node = node_load($node_id);
            $node->status = 1; // publish the node       
            node_save($node);
        }

Save it and it should work like a champ.

#7

This doesn't work for me. Anyone else have any luck with this?

#8

Status:closed (fixed)» active

Sorry to open again, but anyone get this?

#9

I'm currently working on a classified ads site and I got it to work by using a combination of the code supplied in this wonderful tutorial:
http://drupaleasy.com/blogs/ultimike/2009/03/event-registration-ubercart

and the line: $node->status = 1; // publish the node
from stevebab's code above.

Hope this helps.

#10

I'm still having trouble with this. For background, I'm setting the default workflow for my classified content type as unpublished, since otherwise it will be published at creation and not payment (but maybe this is the problem). I'm following the Drupal Easy instructions and the conditional action, per stevebab's advice. I'm still not getting it published at checkout though. Are you suggesting to put the line ($node->status = 1; // publish the node) elsewhere or are you following stevebab's instructions and got it to work as well? Could someone let me know which conditional actions are set up to get this working also?

Thanks a lot for the help.

#11

Nevermind - one of my other conditional actions was faulty.

The tip above works - and the line: $node->status = 1; // publish the node

to the code in the conditional action, as referenced in the drupaleasy.com tutorial

#12

can you please prvide a brief work through how you got your nodes to publish?

#13

all I did was follow the drupal easy tutorial and include the line of php referenced above to the conditional actions snippet of php cited in the tutorial

#14

Status:active» fixed

#15

Status:fixed» closed (fixed)

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

#16

Hi,

I followed the instructions above and my node is now published after the purchase has been done. But i'm asking myself why i'm allready receiving a 'Node is published' message, after the content/node is filled in, but not purchased.

Anyone ideas? Or is it possible to hide this 'node is published' message?

Note: I'm also using the Auto Expire module

Thanks,
Gunther

#17

Wonderful I used the code on #6 on Drupal 7, Ubercart 3 and Rules 2 (the new trigger/actions engine on Ubercart 3) and worked !!! :-)

Thanks!

nobody click here