SearchRecent postsThe Random ToolboxDrupal 7 Setting up variables for use in a template (preprocess and process functions) Rendering Drupal 7 fields (the right way) Linux Secure Copy (scp) command Restrict Free Shipping in Magento Quickbooks Text Connection Ticket Cross-Site Request Forgery (CSRF) jQuery Events: MouseOver / MouseOut vs. MouseEnter / MouseLeave Monthly archive
|
Show SKU in Cart Module - UbercartCreate 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 } } } ?> |