Show SKU in Cart Module - Ubercart

  • strict warning: Non-static method view::load() should not be called statically in /home1/nate01/public_html/sites/all/modules/views/views.module on line 1113.
  • strict warning: Declaration of views_handler_field::query() should be compatible with views_handler::query($group_by = false) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_field.inc on line 1147.
  • strict warning: Declaration of views_handler_argument::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_argument.inc on line 917.
  • strict warning: Declaration of views_handler_argument::query() should be compatible with views_handler::query($group_by = false) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_argument.inc on line 917.
  • strict warning: Declaration of views_handler_sort::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_sort.inc on line 165.
  • strict warning: Declaration of views_handler_sort::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_sort.inc on line 165.
  • strict warning: Declaration of views_handler_sort::query() should be compatible with views_handler::query($group_by = false) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_sort.inc on line 165.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 587.
  • strict warning: Declaration of views_handler_filter::query() should be compatible with views_handler::query($group_by = false) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 587.
  • strict warning: Declaration of views_plugin_query::options_submit() should be compatible with views_plugin::options_submit($form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/plugins/views_plugin_query.inc on line 169.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 136.
  • strict warning: Non-static method view::load() should not be called statically in /home1/nate01/public_html/sites/all/modules/views/views.module on line 1113.
  • strict warning: Declaration of views_plugin_pager_none::post_execute() should be compatible with views_plugin_pager::post_execute(&$result) in /home1/nate01/public_html/sites/all/modules/views/plugins/views_plugin_pager_none.inc on line 69.

Create a folder in your modules directory named uc_show_sku and add these files.

show_sku.info

; $Id$
name = Show SKU
description = Add SKU column to Product and Cart tables
dependencies[] = uc_show_sku
core = 6.x
package = "Ubercart - core (optional)"

uc_show_sku.module

<?php
function custom_module_form_alter(&$form, $form_state, $form_id) {
 
 
    if ($form_id == 'uc_cart_view_form') {
 
    //Add the Titles in the table header row
    $form['items']['#columns']['model']['cell'] = 'SKU';
    $form['items']['#columns']['desc']['cell'] = 'Description';
 
    //Now I am moving around the columns by adjusting the weight
    $form['items']['#columns']['remove']['weight'] = 0;
    $form['items']['#columns']['image']['weight'] = 1;
    $form['items']['#columns']['model']['weight'] = 2;
    $form['items']['#columns']['desc']['weight'] = 3;
    $form['items']['#columns']['qty']['weight'] = 4;
    $form['items']['#columns']['total']['weight'] = 5;
    //dsm($form);
    //There are 6 fields in this array other than the cart items, so I loop through and don't account for those 6
            for($i=0;$i<count(uc_cart_get_contents());$i++){
 
            //Get the info from node_load
            $form['items'][$i]['model']['#value'] = node_load($form['items'][$i]['nid']['#value'])->model . ": "; // Load the SKU from the product node
 
        }
    }
}
?>