8 replies [Last post]
dkruse@drupal.org's picture
Offline
Joined: 04/30/2008
Juice: 45
Was this information Helpful?

First of all, thanks for the great product. I'm in the middle of building my first Ubercart site and I'm amazed at the capability of Ubercart.

Is there a way to have the "Product and its derivatives are shippable" unchecked by default? I'm building a site where most of the products are downloads and only a very few that are shippable. It would be nice to not have to uncheck this every time we enter a new product.

Thanks,
Dalen

glennnz's picture
Offline
Joined: 01/20/2009
Juice: 451
Re: "Product and its derivatives are shippable" not checked by d

Subscribe

tcindie@drupal.org's picture
Offline
Getting busy with the Ubercode.
Joined: 05/15/2008
Juice: 440
Re: "Product and its derivatives are shippable" not checked by d

open modules/ubercart/uc_product/uc_product.module in your favorite text editor,

Browse to the line that declares the form checkbox "shippable" element and change the default value from TRUE to FALSE...

Should be able to find it by searching for shippable

in the D5 version it's on line # 522

You would change lines 519-524 from this:

  $form['base']['shippable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Product and its derivatives are shippable.'),
    '#default_value' => isset($node->shippable) ? $node->shippable : TRUE,
    '#weight' => 10,
  );

To this:

  $form['base']['shippable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Product and its derivatives are shippable.'),
    '#default_value' => isset($node->shippable) ? $node->shippable : FALSE,
    '#weight' => 10,
  );

in the D6 version it's on line # 528

You would change lines 525-530 from:

  $form['base']['shippable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Product and its derivatives are shippable.'),
    '#default_value' => isset($node->shippable) ? $node->shippable : TRUE,
    '#weight' => 10,
  );

To:

  $form['base']['shippable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Product and its derivatives are shippable.'),
    '#default_value' => isset($node->shippable) ? $node->shippable : FALSE,
    '#weight' => 10,
  );

Also for good measure you might want to change the database schema so this column defaults to 0 as well... in the .install file, you would change this line (in D5):

`shippable` tinyint(2) NOT NULL default 1,

to

`shippable` tinyint(2) NOT NULL default 0,

for D6:

      'shippable' => array(
        'description' => t('Boolean flag signifying that the product can be shipped.'),
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ),

To:

      'shippable' => array(
        'description' => t('Boolean flag signifying that the product can be shipped.'),
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),

Follow me on twitter.

hedac's picture
Offline
Joined: 12/14/2007
Juice: 144
Re: "Product and its derivatives are shippable" not checked by d

ideally this would have to be configurable by content type... or by product class

rasskull's picture
Offline
Joined: 02/04/2011
Juice: 5
another way

I know that this is a bit of an older thread, but I stumbled across it looking for an answer to this question. A very small custom module could be made to alter the form instead of editing the original module. Create the module and toss this in there ... voila!

function yourmodulename_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'product_node_form':

    $form['base']['shippable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Product and its derivatives are shippable.'),
    '#default_value' => isset($node->shippable) ? $node->shippable : variable_get('uc_product_shippable_'. $node->type, 0),
    '#weight' => 10,
    );

    break;
  }
}

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: another way

I'm not sure why this thread exists. You can set this as a default on a per-product type / class basis.

Go to admin/content/node-type/product and scroll to the "Ubercart settings" portion. There, you can see a checkbox labeled:

Product and its derivatives are shippable.
This setting can still be overridden on the node form.

--
Help directly fund development: Donate via PayPal!

rasskull's picture
Offline
Joined: 02/04/2011
Juice: 5
nice

There ya go! I need to hunt through settings more before trying to re-invent the wheel Smiling

zareen's picture
Offline
Joined: 01/20/2008
Juice: 81
shipable products unchecked by default

Thanks so much for posting that answer! i've been searching everywhere through the Ubercart configuration and never thought to look at the product content type. You saved me hour!

jasonruyle's picture
Offline
Joined: 01/18/2008
Juice: 235
Re: "Product and its derivatives are shippable" not checked by d

The latest version (d7) has slightly different code.
I noticed that this value is setup in:

Form Function:
  $form['base']['shippable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Product is shippable.'),
    '#default_value' => $node->shippable,
    '#weight' => 10,
  );

function uc_product_prepare($node) {
  $defaults = array(
    'model' => '',
    'list_price' => 0,
    'cost' => 0,
    'sell_price' => 0,
    'weight' => 0,
    'weight_units' => variable_get('uc_weight_unit', 'lb'),
    'length' => 0,
    'width' => 0,
    'height' => 0,
    'length_units' => variable_get('uc_length_unit', 'in'),
    'pkg_qty' => 1,
    'default_qty' => 1,
    'shippable' => variable_get('uc_product_shippable_' . $node->type, 0),
    'ordering' => 0,
  );

  foreach ($defaults as $key => $value) {
    if (!isset($node->$key)) {
      $node->$key = $value;
    }
  }
}

Do you recommend we still update the form? Would prefer to do a hook_form_alter, but not sure which part to update now.