drupal ubercart create node


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



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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.