drupal ubercart create node script


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. if ($order->product_count == 1) {
  2. $form_state = array();
  3. module_load_include('inc', 'node', 'node.pages'); // new for Drupal 6
  4. $nodeTmp = array('type' => 'order'); // a variable holding the content type
  5.  
  6. $form_state['values']['type'] = 'order'; // the type of the node to be created
  7. $form_state['values']['status'] = 1; // set the node's status to Published, or set to 0 for unpublished
  8. $form_state['values']['title'] = 'Some Node Title Here'; // the node's title
  9.  
  10. // here is the problem. trying to access the array in the previous snipplr link.
  11. $form_state['values']['body'] = $updated_order->products[0]->data->attributes['project'][0];// NOT WORKING at the moment. returns empty.
  12.  
  13. drupal_set_message('<pre>'. print_r($updated_order, TRUE) .'</pre>');
  14.  
  15. // the body, not required
  16.  
  17. $form_state['values']['name'] = 'jacobj';
  18. $form_state['values']['op'] = t('Save'); // this seems to be a required value
  19.  
  20. // call the function to create the node, node_revisions, and CCK values.
  21. // Replace "story" with the name of your form / content type
  22. $errs = drupal_execute('order_node_form', $form_state, (object) $nodeTmp);
  23. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.