I am using Conditional Actions in Ubercart on Drupal 6 to create a node when a certain product class is purchased.

Everything is firing correctly. I have check and double-checked the code to see what might be wrong and I can't see it. I'm hoping you might know something that will help.

Here is the code:

$spons_node = node_load($sponsorship['sponsorship_nid']);
$spons_node->field_body[0]['value'] = "Online recurring payment added (".date("m-d-Y H:ia", time()).")\n".$spons_node->field_body[0]['value'];
$spons_node->field_sponsor_amount[0]['value'] = number_format($product->price,2);
$spons_node->field_sponsor[0]['uid'] = $order->uid;
$spons_node->field_payment_type[0]['value'] = $order->payment_method;
$spons_node->field_recurrance_type[0]['value'] = str_replace("every","",strtolower(str_replace(" ","",$product->data['attributes']['Donation Frequency'][0])));
$spons_node->field_initial_order_id[0]['value'] = $order->order_id;
$spons_node->field_recurring_item_id[0]['value'] = (int) $new_query['pfid'];
$message = "Sponsorship for <em>".$product->title."</em> has been updated.";
uc_order_comment_save($order->order_id, '0', $message, $type='admin', $status = 1, $notify = FALSE);
$spons_updated = TRUE;

I used drupal_set_message("<pre>".print_r($spons_node,TRUE)."</pre>");, inserted just before the node_save command, to ensure the node was being built properly. All of the fields were updated correctly.

But something is going on with node_save. My Drupal installation is telling me that the node in question was updated, but none of the changed data is being stored. It looks like it's defaulting to the cached data.

I've also tried using node_load($sponsorship['sponsorship_nid'],NULL, TRUE); to force a cache reload, but that's not working.

Ideas welcome.

  • 3
    try node_load(FALSE, NULL, TRUE); after saving the node to clear the cache and see what happens when you load it again...
    – Jimajamma
    Mar 16, 2012 at 18:07
  • 1
    You. Are. My. Hero. Totally worked! Thank you so much.
    – merauluka
    Mar 17, 2012 at 2:41


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.