How to create a product class programmatically in D7 / Ubercart 3 I'm looking to create a new module that when enabled will create a new content type and create an ubercart product class for it automatically.

I've tried googling and searching stackexchange for a few days but couldn't find much that is current or applicable to D7/U3 (or so I think).

There's plenty of info on creating a node programmatically.

My question is: Once I have created the node, how do I programmatically "productize it"?
Thanks to Clive for pointing me in the right direction. As requested here is a code snippet I used in my module. I was able to take the code found in uc_product_class_form_submit() and make minor changes to make it work for my situation.

Essentially, in my module, I'm using hook_enable to call a helper function which checks for an existing product class. If it doesn't exist, then it creates it (as well as the node type). My module will go on to do more, but this is the relevant piece. (more specifically the function uc_suggested_donation_levels_add_product_class).

&lt;?php

/**
 * @file uc_suggested_donation_levels.module
 * Adds up to 4 donation levels including a "you choose" amount.
 */
// Constants
define('DONATION_PRODUCT_TYPE_MACHINE_NAME', 'giving_project');
define('DONATION_PRODUCT_TYPE_READABLE_NAME', 'Giving Project');
define('DONATION_PRODUCT_TYPE_DESCRIPTION', 'Adds up to 4 donation levels including a [you choose] amount.');
define('DONATION_PRODUCT_TYPE_ERROR', 'Content type already exists in database. No need to re-create.');

/**
 * Implements hook_enable.
 * When this module is enabled it will check if the product type exists,
 * if not, then it will create it and productize it.
 */
function uc_suggested_donation_levels_enable() {
  uc_suggested_donation_levels_add_product_class();
}

function uc_suggested_donation_levels_add_product_class() {
  // first check to see if this product already exists.
  if (in_array(DONATION_PRODUCT_TYPE_MACHINE_NAME, uc_product_types())) {
    // The product type already exists, abort.
    watchdog('uc_suggested_donation_levels', DONATION_PRODUCT_TYPE_ERROR, array(), WATCHDOG_INFO);
    drupal_set_message(DONATION_PRODUCT_TYPE_ERROR, 'status');
    return; 
  } 

  $pcid = DONATION_PRODUCT_TYPE_MACHINE_NAME;

  $result = db_merge('uc_product_classes')
    -&gt;key(array('pcid' =&gt; $pcid))
    -&gt;fields(array(
      'name' =&gt; DONATION_PRODUCT_TYPE_READABLE_NAME,
      'description' =&gt; DONATION_PRODUCT_TYPE_DESCRIPTION,
    ))
    -&gt;execute();

  db_update('node_type')
    -&gt;fields(array(
      'name' =&gt; DONATION_PRODUCT_TYPE_READABLE_NAME,
      'description' =&gt; DONATION_PRODUCT_TYPE_DESCRIPTION,
    ))
    -&gt;condition('type', $pcid)
    -&gt;execute();

  uc_product_node_info(TRUE);

  if ($result == MergeQuery::STATUS_INSERT) {
    variable_set('node_options_' . $pcid, variable_get('node_options_product', array('status', 'promote')));

    if (module_exists('comment')) {
      variable_set('comment_' . $pcid, variable_get('comment_product', COMMENT_NODE_OPEN));
    }

    module_invoke_all('uc_product_class', $pcid, 'insert');
  }
  else {
    module_invoke_all('uc_product_class', $pcid, 'update');
  }

  node_types_rebuild();

  $type = node_type_get_type($pcid);
  node_add_body_field($type, t('Description'));
  uc_product_add_default_image_field($pcid);

  menu_rebuild();

  drupal_set_message(t('New donation content type and product class has been created.'));
}