2 replies [Last post]
Max_Headroom's picture
Offline
Joined: 09/01/2008
Juice: 47
Was this information Helpful?

Hi
I am developing a payment module but ran into a problem with workflow-ng not changing my order status.
When a successful payment is made, the following code execute:

<?php

$output

= uc_cart_complete_sale($order_check, variable_get('uc_new_customer_login', FALSE));
   
uc_order_comment_save($order_check->order_id, 0, $somestring);
   
uc_payment_enter($order_check->order_id, 'Setcom', $somearray['tnx_amount'], 0, NULL, $somestring);
   
workflow_ng_invoke_event('payment_received', $order_check->order_id, $user->uid == 0 ? $account : $user);
   
?>

The workflow_ng_invoke_event triggers an event:

<?php
$events
['payment_received'] = array(
   
'#label' => t('Payment received'),
   
'#module' => t('Setcom'),
   
'#arguments' => array(
     
'order' => $order_arg,
     
'account' => array('#entity' => 'user', '#label' => t('customer user account'))
      ),
    );
?>

Which is basically a copy of the 'Customer completes checkout' event.
The event gets invoked, I've tested it by making the event do a simple message action without a condition.
But I want to change the order status from "pending" to a custom status named "setcom_payment_received". (I upload the custom statuses to database during module install).
I set up a wf-ng configuration > if condition: order_status = 'pending' then action: change order_status to 'setcom_payment_received'.
This does not work. I removed the condition, but the action still does not work.

Something to note: function uc_cart_complete_sale() invokes the 'Customer completes checkout' event. If I use this to do the action (and condition) mentioned above, it works fine (change the order status). My event gets invoked after the uc_cart_complete_sale() function, but does not change the order status.

Any ideas?

(In case you wonder why I am trying to re-invent the wheel: I want to set custom statuses for the other payment types this gateway offers)

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Workflow-ng and order status problem.

You're passing in the order id, but it should be the entire order object. Just like it's the entire $account or $user and not the uid.

Max_Headroom's picture
Offline
Joined: 09/01/2008
Juice: 47
Re: Re: Workflow-ng and order status problem.

Thank you very much, Lyle!