I have a client that is looking at creating temporary nodes that could be converted to Ubercart products. However, there are some fields from Ubercart that are not created via CCK, and I'm curious if anybody has tried or had any success.

Sincerely,
Rene

Comments

alcroito’s picture

Well, I'm not sure if Ubercart is a node, but if it is, the 6.x version of the module has a hook that lets you make some additional changes while the node conversion, so you can create a module to deal with ubercart products. But there is a need to backport that feature to the 5.x version, and I currently don't have the time.

rhache’s picture

Status: Active » Closed (fixed)

I've tested this and can confirm it doesn't work.

Thanks,
Rene

websule-old’s picture

Hi Rene,

It is possible with drupal 6.14, We just did it.

Let me know if you still need help with this?

marrop’s picture

Version: 5.x-1.4 » 6.x-1.4

I would like to create a complex node (e.g. via CCK) and make this type a ubercart product. Essentially, the customer is to "configure" the product before checkout adding an address, a multi line text, a date etc.

I'm using 6.x-1.4 and ubercart 2. Is the above somewhat like what you have succeeded in doing? Any pointers and advice would be greatly appreciated!

Thanks

3goose’s picture

Copy the exact machine readable name of the content type you want converted to an ubercart product.

Browse to Administer › Store administration › Products > Manage classes

Enter the machine readable name of the content type into the class ID field and fill out the rest of the form. That content type is now an ubercart product!

texas-bronius’s picture

..and by the same token, you can demote a node from being a product by deleting the Product Class under store administration (but don't delete the Content Type under admin>>Manage Content!). Not sure what this does for Ubercart-managed cck fields.

ocamp’s picture

how did you fill in the product fields?

I cant even seem to edit them after I convert a node to a product

texas-bronius’s picture

ocamp- Can you provide more info? Are you logged in as someone with permissions to edit Ubercart Products (store admin?) or the content type?

ocamp’s picture

hi, ive tried with admin, and other users with varied permissions, always get same result though.

I create a node, tried with a range of different types.

Convert that node to a product, the cck fields that can be converted to the new node do, and the fields that cant be converted get discarded.

I have the ubercart product with additional cck fields, filled in from the node that was converted.

Now I can click to edit the product, and edit the cck fields, and node elements such as node author etc. and click save, when i save it the cck/node elements get saved, the node product fields dont get saved.

texas-bronius’s picture

ocamp- How are you "converting from cck to uc product?" I don't get why any cck fields would not be "supported" and would get discarded.

ocamp’s picture

hi, no i mean the cck fields get discarded when there isnt a relevant field on the product.

The situation is,
a user might upload artwork/portfolio, So ill have a content type called image, add cck file fields, for the users to upload their art work.

Then the user may decide that they want to sell their art work, not just display it. So i have the option to convert the image type to a product type.

Clicking on the convert tab at the top of the node works, the image type gets converted into product, the file field from image gets put in the file field on the product content type. Publishing/unpublishing the node, adding url alias, changing the image, etc all work,

but then the product specific fields dont work. A user can click to edit the product, and edit any field, but only the cck fields get saved. SKU, price, etc can be edited, but do not update when the node is saved.

alcroito’s picture

Version: 6.x-1.4 » 6.x-1.x-dev
Status: Closed (fixed) » Fixed

I've added code to make ubercart conversion work. Basically, if you use the initially created "product" content type, you should have no problems.

alcroito’s picture

And yeah, it's in the dev release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

samgreco’s picture

Version: 6.x-1.x-dev » 6.x-1.7

I am seeing this issue with 6.x-1.7.

I converted an existing Product to a new Product Type (made from a new class). Recreated the 4 custom CCK fields I had. The CCK fields converted without a problem.

Unfortunately, all of the price and shipping related fields (standard Ubercart fields) did not. And if I try and manually enter those after the conversion, it will not save any of the values. Always shows 0.

samgreco’s picture

Status: Closed (fixed) » Active
Zalatar’s picture

I am seeing the same issue in Post 15. I create a "Product". Then when I convert that product to another Ubercart node type, I lose the pricing and I am unable to edit the SKU number. If I try to edit the SKU, upon saving the node, it deletes the SKU I put in and says it needs to have one due to it being a required field.

Hopefully someone has a fix for it.
Thx,
Z

islanddogg’s picture

I'm having the same issues regarding updating product information. I converted one product class to another one, but I cannot update the product information fields, as the info is not saved.

rkeppner’s picture

I think I've found a workaround for the problem described in posts 15 and 18, converting one Ubercart product class to another.

In the end, all I had to do was check the "Create new revision" box under "Revision information" and the changes saved correctly. Hopefully this helps a few frustrated converters like myself.

momper’s picture

sub

sherred’s picture

I fixed the issue described in posts 15 & 18, i.e. converting a Ubercart Product node to a Ubercart Product Class node by modifying one line of code in uc_product.node_convert.inc :

Line 25 From:
if ($data['node']->type == 'product' && module_exists('uc_product')) {

To:
if (in_array($data['node']->type, uc_product_types()) && !in_array($data['dest_node_type'], uc_product_types()) && module_exists('uc_product'))

This way when both source and destination nodes are products the product does not get deleted from uc_products so product information such as SKU & cost remain linked to the node.

gregaltuna’s picture

Hey all, sorry, but I'm a bit of a newb with Ubercart. The client's got books full of user bios. Need a product where the user fills out form then selects how many editions to subscribe to below it.

I've been banging my head against this real bad. First thought of using node checkout to buy the node, but couldn't figure out how to pass the value from the cck field to the cart.

So I stumbled upon this thread. But now I'm in the same predicament. Any way to pass the value of one of the CCK fields to the cart as the "price"???????

My PHP is still novice, but I know just enough to be dangerous so please be gentle.

MPforce’s picture

Priority: Minor » Normal

Thanks to sherred. This was helpful information. Although, I have little to no PHP knowledge. I have searched for the original:

Line 25 From:
if ($data['node']->type == 'product' && module_exists('uc_product')) {

But can't find code resembling this in any of the .inc files. Any more specific information on where to put:

if (in_array($data['node']->type, uc_product_types()) && !in_array($data['dest_node_type'], uc_product_types()) && module_exists('uc_product'))

????? Thanks.

shingle’s picture

In response to #21

In my version there are 4 places the check:

if ($data['node']->type == 'product' && module_exists('uc_product')) {

is done, one for 'insert', 'delete', 'options' and 'options validate'. Line 25 is only for 'delete'. Should the check be modified to:

if (in_array($data['node']->type, uc_product_types()) && !in_array($data['dest_node_type'], uc_product_types()) && module_exists('uc_product'))

only for 'delete' or all 4 checks?

drupalmeister’s picture

Hi,

I would like to convert a plain vanilla node to an ubercart product using the "node convert templates" (and have it produce an action).

I have two content types: "dummy_product" (which is NOT an ubercart procduct, but rather a plain content type with CCK fields) and "product" (Which IS indeed the default ubercart product class).

Now, I need to allow my customers to create "dummy_product" and only on some certain events will I want to use the action from the 'node convert' template to convert a 'dummy_product' to an ubercart 'product'.

If I currently try to convert anything that is not an ubercart product to an ubercart product, I get a form asking me to fill out the 'Product Information' (Preceeded by the text "Also the following parameters are available"), and I have to fill in the SKU and other information for the newly converted product.

What I would like to do is have some CCK fields on the original 'dummy_product" which will be converted and their values should be inserted into predefined mapped fields. For example, I would like to have a CCK field called 'dummy_sku' which when converted to a 'product' type should be automatically inserted as the 'product' SKU, and so on for price, weight, etc.

I would very much appreciate if anyone could give me some pointers to fix this issue, or help explain what needs to be done so that I can look it up and maybe contribute this back to the module.

alcroito’s picture

Your best bet is to write a custom module which uses the node_convert API.

You'll have to give all the necessary arguments to node_convert_node_convert(), and write an implementation for hook_node_convert_change, probably re-using the one in uc_product.node_convert.inc, which will transfer the cck field values into the corresponding ubercart fields. You'll also have to hack the module, and add your include to be loaded in hook_init().

By the time your hook_node_convert_change() is called, the node will already be converted in the database, but the cck values will still be available in the passed $node variable.

drupalmeister’s picture

Thanks so much. I will look into it, and I hope I will be able to write such a module. Thanks so so much for your time and effort. I very much appreciate it.

Baibhav Kumar’s picture

Thanks buddy your post was really helpful

jasonabc’s picture

@sherred - a thousand thank-yous for posting this solution in #21! Was noticing all the price and shipping data was being lost when converting from the default "Product" to a custom Product Class. Your solution solved the problem - thanks!

forhaud’s picture

Issue summary: View changes

@sherred - a thousand thank-yous for posting this solution in #21! Was noticing all the price and shipping data was being lost when converting from the default "Product" to a custom Product Class. Your solution solved the problem - thanks!

+10000

Why is not entered in the official version?