Hi,

I'm working on a small module to disable the the sku and price field from being required in ubercart's product page form. I used coder but it only got me so far. I don't understand what the problem is. I just know that when i enable it i get an error saying there is something wrong iwth line 13 which is the line that has the form_id in it. I can't figure out what is wrong with it. Could someone help me out?

<?php
// $Id$

/**
* @file
* Module to hold my customizations to Ubercart
*/

/**
* Implementation of hook_form_alter()
*/
function skudisable_module_form_alter(&$form, &$form_state, $form_id ) {
  if ($form_id == 'product_node_form') {
    $form['base']['model']['#required'] = FALSE;

  }
}

Comments

nevets’s picture

Nothing pops out, though the error might help to pinpoint the problem. If nothing else, delete the line a re-type (in case there are non visible characters)

beckyjohnson’s picture

Oh my god! I can't believe it! You're right. there were hidden characters in it screwing it up! I'm really happy that you suggested I check for this because now it works! Thank you.

There is one more field I want to disable, which is also part of product_node_forum. Why type of syntax would I use to continue this code argument down to un-require other fields?

Thanks so much!

Becky

bwv’s picture

Please correct me if I am wrong, but are there not options for these at admin/config/product settings?
----------------------------------------------------------------------
http://classicvinyl.biz
http://music.bwv810.com
http://davidhertzberg.com
http://association.drupal.org/user/1207

I am a writer, researcher and solo drupal freelancer

beckyjohnson’s picture

There are options in the admin section for not showing these on the pages but when you fill out the form, even if you don't display it on the page, you still have to type in a sku and a list price but i'm trying to use uber cart as a product showcase. Nothing is really being sold here, nothing has a price really. It's just a catalogue with info in it.

And I'll try re-typing the line and checking for hidden characters.

Becky

nevets’s picture

If you are not selling stuff and just presenting a catalog it would seem using CCK and views would be easier and more straightforward.

bwv’s picture

Ditto.
----------------------------------------------------------------------
http://classicvinyl.biz
http://music.bwv810.com
http://davidhertzberg.com
http://association.drupal.org/user/1207

I am a writer, researcher and solo drupal freelancer

beckyjohnson’s picture

Thanks for that suggestion. I think i'll try it out. Although, off the top of my head, there are some things that ubercart does that I 'm not sure about how i would program on my own. Such ascreating a page that shows a grid view of the products. Or making a themed porthole kind of page that shows all the catalogue options. Like here:http://beta-wimaxforum.org/catalog . Any suggestions?

nevets’s picture

For the first part there is an add on to views that provides a grid view. For the second part, access to the url is denied.

beckyjohnson’s picture

Thanks for letting me know that access was denied for the catalog link. YOu can see a screenshot of what I mean here: http://www.beta-wimaxforum.org/catalogue.jpg

Also the add on to views that creates a grid: is this an add on module or is it that I have create a new view in Views but views has the capabilities to already give me a grid view? Sorry I'm really new to views. I've barely done anything with it.

Becky

gbrussel’s picture

The Views2 module for D6 already has the Grid formatting option available. When you create your view, under the "Basic Settings", there's a Style option, one of the options there is "Grid".

beckyjohnson’s picture

I have another question. Since I'm new to module writing and coding, as an exercise, I went through and modified my form by using hook form alter()

This is what I have now:

<?php
// $Id$

/**
* @file
* Module to hold my customizations to Ubercart
*/

/**
* Implementation of hook_form_alter()
*/
function disable_module_form_alter(&$form, &$form_state, $form_id ) {
 if ($form_id == 'product_node_form') {
    $form['base']['model']['#required'] = FALSE;
    $form ['base']['prices']['sell_price']['#required'] = FALSE;
    //modify attributes of existing fields
    $form['base']['prices']['sell_price'] = array('#type' => 'hidden');
    $form['base']['prices']['cost'] = array('#type' => 'hidden');
    $form['base']['prices']['list_price'] = array('#type' => 'hidden');
    $form['base']['shippable'] = array('#type' => 'hidden');
    $form['base']['weight'] = array('#type' => 'hidden');
    $form['base']['dimensions'] = array('#type' => 'hidden');
    $form['base']['pkg_qty'] = array('#type' => 'hidden');
    $form['base']['default_qty'] = array('#type' => 'hidden');
    $form['base']['ordering'] = array('#type' => 'hidden');
   
    }

}

The only field I left in the "Product Information" fieldset was the SKU field. My new question is , how do i expand the field set to extend around all of my other unique product information fields that I have added.
I found the code easily in the ubercart product module, but I'm not sure what to do to extend it. I think it has something to do with adding the variable [base] to all my new fields but I don't know how to do it.
Ubercart code

 $form['base'] = array('#type' => 'fieldset',
    '#title' => t('Product information'),
    '#collapsible' => true,
    '#collapsed' => false,
    '#weight' => -1,
    '#attributes' => array('class' => 'product-field'),
  );

Thanks for all the input and help so far. I still may redo this using CCK but it's a good learning experience for me to try it this way first.

Becky

beckyjohnson’s picture

I have another question. Ubercart gives me the ablity to make thumbnails for each product as well as a full size version. I know i can make the full size version with CCK image field but how to I make the thumbnail size image for each product?

Thanks,
becky

bwv’s picture

Use the imagecache module, a real work of genius.
----------------------------------------------------------------------
http://classicvinyl.biz
http://music.bwv810.com
http://davidhertzberg.com
http://association.drupal.org/user/1207

I am a writer, researcher and solo drupal freelancer