11 replies [Last post]
Stutzer's picture
Offline
Joined: 09/03/2009
Juice: 24
Was this information Helpful?

Hi all!

I've been dug in API and FAQ for last 2 hours but I can't find answer on my subject question

I have my_module, that define complicated content type with many fields. So I need make this content type a ubercart product. Programmaticaly.

Thanks for answers!

TR
TR's picture
Online
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3424
Re: How to say ubercart that my_module content type is a product
<tr>.
Stutzer's picture
Offline
Joined: 09/03/2009
Juice: 24
Re: Re: How to say ubercart that my_module content type is a pro

Thanks for your answer but I've already read this article. I've found there only information about extend product content types with extra fields via CCK module. I don't use CCK, I use hook_node_info() to define new content type that I want to make a product.

By the way, I'm using D6 and UC2

Stutzer's picture
Offline
Joined: 09/03/2009
Juice: 24
Re: How to say ubercart that my_module content type is a product

I'm still searching for solution.
I've found that I can link existing content type with Ubercert by specifying machine content type name at admin/store/products/classes
But if my content type provided by my module, I have following error message
This is a node type provided by another module. Only custom node types may become product classes.

zeezhao's picture
Offline
Joined: 04/23/2008
Juice: 969
Re: Re: How to say ubercart that my_module content type is a pro
berkes's picture
Offline
Joined: 11/08/2009
Juice: 4
Re: Re: Re: How to say ubercart that my_module content type is a

That link describes how to convert CCK types. Not types made by a module.

I have 'way2cinema_event' which is a module-type and I would like to turn this into a product.
I think this is what the original author wants too.

regards Bèr

- Drupal Services - http://webschuur.com
- Drupal Training - http://wizzlern.nl

Cayenne's picture
Offline
Joined: 01/01/2009
Juice: 533
Re: Re: Re: Re: How to say ubercart that my_module content type

Maybe I'm a hacker, but I added a filter that says "Price >= -$6666"

Works fine. The price is a value I use as an error elsewhere, but the key is to have a stupidly low number

berkes's picture
Offline
Joined: 11/08/2009
Juice: 4
SOLVED - hook_product_types

[berkes] repost from a question this morning: I have read several posts and manuals on "how to use nodetype X as product" but none tell me that it actually is possible. i /do/ know it is possible to convert types to products, but I cannot find how to use a type, instead of converting.
... problem also described here http://www.ubercart.org/forum/development/12867/how_say_ubercart_my_modu...
anyone with a hint or a "no, is impossible" or anything would be fine Smiling Saves me diving into übercart tomorrow.

[dereine] berkes: its very easy
[berkes] I like the sound of that, dereine Smiling

[dereine] implement hook_product_types
http://pastebin.com/m14f58761

[berkes] http://api.lullabot.com/hook_product_types/5 it is, dereine. thx a lot!

NewZeal's picture
Offline
Joined: 04/18/2008
Juice: 56
deleted

I thought I had a solution. Turns out I didn't.

madmatter23's picture
Offline
Joined: 09/21/2010
Juice: 3
Re: How to say ubercart that my_module content type is a product

I'd also like to be able to accomplish this. In my case, I'm using the Image module to create galleries for a photographer. I'd like to also make each image node available as a product for purchase via ubercart.

Has anyone found a solution for this?

Stutzer's picture
Offline
Joined: 09/03/2009
Juice: 24
Re: Re: How to say ubercart that my_module content type is a pro

Actually, there is no way out for UC2.
This feature will be realized in UC3, I hope. See this issue http://drupal.org/node/525612

I had to rewrite my module using hook_nodeapi.

bensey's picture
Offline
Joined: 07/20/2011
Juice: 16
Dodgy workaround for this problem...

Hi all,

my dodgy workaround for this issue is to disable the custom content type check.
There is obviously a reason Ubercart likes to avoid allowing this, but I've done it many times without a problem.

Find the following function in uc_product.admin.inc and comment out the lines as shown below.

This prevents Ubercart from checking whether your content type is a custom one, and it happily adds the content type as a product class.

As this only needs to happen once, afterwards you can upgrade to new Ubercart releases and forget about the changes unless you wish to add another class later on...

function uc_product_class_form_validate($form, &$form_state) {
  if ($form['pcid']['#type'] == 'textfield') {
    $type = node_type_get_type($form_state['values']['pcid']);
    if ($type) {
      if ($type->base == 'uc_product') {
        form_set_error('pcid', t('This product class already exists.'));
      }
//      elseif ($type->custom == 0) {
//        form_set_error('pcid', t('This is a node type provided by another module. Only custom node types may become product classes.'));
//      }
    }
  }
}

Can anyone comment on why this shouldn't be done, and for what reasons Ubercart is checking this?

Cheers.