diff -rNu uc_node_checkout.old/uc_node_checkout.info uc_node_checkout/uc_node_checkout.info --- uc_node_checkout.old/uc_node_checkout.info 2009-01-30 15:01:49.000000000 -0400 +++ uc_node_checkout/uc_node_checkout.info 2009-04-13 08:14:24.000000000 -0300 @@ -2,6 +2,7 @@ name = Node Checkout description = Adds a product to the cart when a checkout node is created. dependencies[] = uc_cart +dependencies[] = views package = Ubercart - extra core = 6.x diff -rNu uc_node_checkout.old/uc_node_checkout.module uc_node_checkout/uc_node_checkout.module --- uc_node_checkout.old/uc_node_checkout.module 2009-01-30 12:59:04.000000000 -0400 +++ uc_node_checkout/uc_node_checkout.module 2009-04-10 10:03:24.000000000 -0300 @@ -6,6 +6,15 @@ * Associate node types with products on your site that customers can purchase. */ +/** + * Implementation of hook_views_api(). + */ +function uc_node_checkout_views_api() { + return array( + 'api' => '2.0', + 'path' => drupal_get_path('module', 'uc_node_checkout') .'/views' + ); +} /** * Implementation of hook_menu(). @@ -638,7 +647,7 @@ function uc_node_checkout_order($op, &$arg1, $arg2) { switch ($op) { // Save node to order product associations upon order submission. - case 'submit': + case 'save': // Loop through each product on the order. foreach ($arg1->products as $product) { // If it has a node checkout nid... diff -rNu uc_node_checkout.old/views/uc_node_checkout.views.inc uc_node_checkout/views/uc_node_checkout.views.inc --- uc_node_checkout.old/views/uc_node_checkout.views.inc 1969-12-31 20:00:00.000000000 -0400 +++ uc_node_checkout/views/uc_node_checkout.views.inc 2009-04-10 13:31:02.000000000 -0300 @@ -0,0 +1,50 @@ + array( + 'left_field' => 'nid', + 'field' => 'nid') + ); + + // Checkout Node Relationship - custom handler + $data['uc_order_products']['order_product_id'] = array( + 'title' => t('Checkout Node'), + 'help' => t('The associated Checkout Node'), + 'relationship' => array( + 'base' => 'node', + 'field' => 'nid', + 'handler' => 'views_handler_relationship_node_checkout', + 'label' => t('Checkout Node') + ), + ); + + return $data; +} + +/** + * Implementation of hook_views_handlers(). + */ +function uc_node_checkout_views_handlers() { + return array( + 'info' => array( + 'path' => drupal_get_path('module', 'uc_node_checkout') . '/views', + ), + 'handlers' => array( + 'views_handler_relationship_node_checkout' => array( + 'parent' => 'views_handler_relationship') + ) + ); +} diff -rNu uc_node_checkout.old/views/views_handler_relationship_node_checkout.inc uc_node_checkout/views/views_handler_relationship_node_checkout.inc --- uc_node_checkout.old/views/views_handler_relationship_node_checkout.inc 1969-12-31 20:00:00.000000000 -0400 +++ uc_node_checkout/views/views_handler_relationship_node_checkout.inc 2009-04-10 10:09:01.000000000 -0300 @@ -0,0 +1,66 @@ +definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field']; + + $this->ensure_my_table(); + + $def = $this->definition; + + if (!empty($this->options['required'])) { + $def['type'] = 'INNER'; + } + + // Setup first join + $def['table'] = 'uc_node_checkout_order_products'; + $def['left_table'] = $this->table_alias; + $def['field'] = $this->field; + $def['left_field'] = $this->field; + + $join = new views_join(); + $join->definition = $def; + $join->construct(); + $join->adjusted = TRUE; + + // use a short alias for this: + $alias = $def['table'] . '_' . $this->table; + + $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship); + + // Setup second join + $def['table'] = $this->definition['base']; + $def['left_table'] = 'uc_node_checkout_order_products'; + $def['field'] = $base_field; + $def['left_field'] = $base_field; + + $join = new views_join(); + $join->definition = $def; + $join->construct(); + $join->adjusted = TRUE; + + // use a short alias for this: + $alias = $def['table'] . '_' . $this->table; + + $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship); + } +}