30 replies [Last post]
sajt's picture
Offline
Joined: 02/17/2008
Juice: 47
Was this information Helpful?

Hello,

I like to add some extra fields to the products in a laptop store. For example: memory, processor type etc. Some is text field and some is checkbox. I like to store it, show it to the user, and search on it, if it is possible.

How can I make it?

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6854
The magical and wondrous CCK

The magical and wondrous CCK modules. It should already be in use on your site to provide image support for your products. Start by poking around the Content types page in the administration and add fields to your product types. If you need more product types for more differentiation, head over to Store administration > Products > Manage classes.

sajt's picture
Offline
Joined: 02/17/2008
Juice: 47
Re: The magical and wondrous CCK

Thanks. Later I find this. I forget to check some checkbox.

cway's picture
Offline
Joined: 02/28/2008
Juice: 32
add field to product

I, too, am trying to create additional products fields for my products.
I've created the field 'year', but I can't figure out how to get this field to show when I go to create a new product.
Does anybody have any ideas?
Thanks!
Cway

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15450
Re: add field to product

cway, did you add this field using CCK? If so, it should be on the form automatically...

cway's picture
Offline
Joined: 02/28/2008
Juice: 32
Re: Re: add field to product

Ryan, thanks for the quick response.
No. I don't have cck installed.

Actually, the field IS on the new product page. It's at the very bottom. I didn't see it before.

Thanks, Ryan.
Cway

kamehameha's picture
Offline
Joined: 12/28/2009
Juice: 9
Re: The magical and wondrous CCK

How can I add products field and list it just below the default products fields?

Hi Lyle;
Ubercart shipped with several default product fields as follows:
Display price
Image
SKU
List price
Cost (seen only by 'administer products' permission)
Sell price
Weight
Dimensions
Add to cart
I want to add some definitions as follow:
Size
Color
Package(like box, carton, etc)
Min. order quantity
The Size and Color can be done by adding ubercart attributes because they have some options and the customers may pick one from the selection list.
But as regard the Package, I do not want the customers to pick one from a selection list or fill in a textfield because the package method is according to different kinds of products, and only the site admin or content editor can decide which package method should be for a given kind of product.
I tried to add a package product field via CCK, but it show up far away under the default fields like Weight, Dimension, and Price. Its' ugly and looks like these definitions are talking about different things.
Can you tell me how can I list the CCK added customized product fields list just below the default product fields? I believe there must be some site using Package product field, do you have a demo? or can I find a module or patch to add some product fields to the list of ubercart default product fileds?

Thanks in advance!

milplus's picture
Offline
Joined: 11/27/2010
Juice: 180
additional Products fields CCK not displaying in products grid

hi
I know thisthread is not updated.
I hav eissue becuase using CCK I'm adding 5 extra fields to the ubercart product base fields (SKU etc etc). However following your instruciton (I've also installed UC SELL CCK module) I cannot get any fields added displayed in the Base Product Fields Mask where you enable or disable fields.

I'm getting lost in a glass of water as we say. Can you help me in understanding .
I've enabled also the CONTENT FIELD PRIVACY for these 5 additional fields but no way to get them displayed.

hope you can support.

thanks

jevous's picture
Offline
Joined: 08/03/2011
Juice: 14
having the same problem

I have two extra fields for a product (book in my cas), its the writer and the publisheer.
I cant understand how to make them visible in the product grid.
Can anyone help me with this?

thirupathi43's picture
Offline
Joined: 07/01/2012
Juice: 3
One time Activation Charge field

Hi Lyle, How can i add Activation charge field in product and that can be add to total money value...

konsumer's picture
Offline
Joined: 03/06/2008
Juice: 6
CCK fields

I really wish that "classes" were just content-types. I feel like this would make using CCK alot easier.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6854
Re: CCK fields

They are content types. The difference is that they're using the uc_product module to handle the default product fields. Go ahead and use CCK on any extra fields you need. Then you can use Contemplate to display all the fields any way you like.

konsumer's picture
Offline
Joined: 03/06/2008
Juice: 6
Re: Re: CCK fields

What I mean is there is all this extra stuff. Like in order to not have shipping for a single content-type show up in the edit form, I have to make a hook_form_alter() and hide it. If I don't agree with the product model (I don't have 3 price fields for any products) and the client will be way overwhelmed by options that have nothing to do with their stock, then I have to do alot of tweaking. I think it would be awesome if it just added a content-type (using the default product fields as you say) and they were actually controllable in UI (CCK style) so I could remove fields I don't use. The ecommerce module uses "features" like this (which in my install of ubercart, there are no "features") to modularize the product model, but it's still not as cool as being able to just get rid of things that I really don't need, or change the labels in the UI, or make fields not required by clicking a checkbox.

Ubercart already has a CCK dependency (correction: it suggests it's use), so it wouldn't add anything. This would mean that I could use the muriad of other CCK modules to play with the values, too, like attributes are just tokens for SKU, and a computed field for price. This would mean that I could use the UI to make crazy price adjustments like "if they order a comb, a brush is %50 off". Autonodetitle or pathauto on things like product-attributes? To do things like this now, I am copying values from CCK fields, and manipulating built-in fields in hook_cart_item() and hook_form_alter(). I think it'd be great if I didn't have that extra step for advanced stuff (unless, of course, there wasn't already a CCK way of doing it, in which case I could write a much smaller custom module, that could be used in many applications.)

I mean, ubercart really great, don't get me wrong, but I have spent alot of time var_dump()'ing $form, and $item, and playing around with things, in order to change the way the product edit forms are displayed (the API reference is awesome, by the way.) I think it would save time, at least for me, if the product-classes were just content-type dumps to be used as defaults, but everything was manipulatable, and mapped to things the cart needs (like price, weight, and stock.)

I guess I imagine my perfect shopping cart acting more like views (and alot of the functionality could actually be handled by views, as it is in ubercart) in that you can override frontpage and taxonomy_term in UI, to do whatever you want to it. I think if it were all built with sensible defaults (just like ubercart) it wouldn't be any harder to get going for new people, but it would be super-easy to customize (and have tons of cool features, out of the box) for anyone who has worked on a views/cck site. If the cart was just a node holder, or some sort of view, and shipping and payment was just a node-processor (all 3 using using mapping to the CCK fields that represent things like weight, price, and stock) then I wouldn't have write as much code.

Maybe I'm just not understanding how ubercart works, so forgive me if I am missing something, but I am really addicted to the amount of cool stuff you can do with just CCK/Views, and this has been my only real frustration with ubercart. Other then that, I think it's perfect, and it's definitely more cohesive and easier to work with, for me, then the ecommerce module.

Sorry for the rant...

ystanley's picture
Offline
Joined: 02/17/2008
Juice: 11
Re: Adding extra fields to the product

I am using CCK to add additonal fields to the product content type. I realised that the SKU, list price, cost, and sell price are not CCK fields and therefore not manageable by CCK. I am wondering what is the best way of manipulating of the SKU field such that I am able to place the SKU field under another fieldset along with other CCK fields. Can this be done using alter form hook or do I really need to hack into the uc_product.module?

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15450
Re: Re: Adding extra fields to the product

@cway: if you're adding this with hook_form_alter(), you can change its positioning using weights. If it's simply a field to enter in a year, I'd recommend the CCK module to ya.

@ystanley: in order to avoid an outright dependency on CCK, these default product fields are handled separately as you've found out. However, instead of hacking the core module, you can instead write a custom module that uses hook_form_alter() to reorganize and adjust what fields are displayed to the user.

konsumer's picture
Offline
Joined: 03/06/2008
Juice: 6
hook_form_alter()

That's what I was explaining above. I went this route, and it works ok, I just wish that I could've done it all without having to make a hook_form_alter (I thought ubercart does depend on CCK already, but looking at the project page, it appears it only "recommended", so this makes a little more sense to me, now)

Here's what I did to hide the other price fields (in a custom module):

<?php
function YOURMODULE_form_alter($form_id, &$form){
  if (
$form_id=='YOURNODETYPE_node_form'){
   
$form['base']['prices']['list_price']['#type'] = 'value';
   
$form['base']['prices']['cost']['#type'] = 'value';
  }
}
?>

Change YOURMODULE to the name of your custom module that you put this function in, and YOURNODETYPE to the content-type for the nodes that you want to modify.

I actually have to do a bunch of other stuff to the edit form (conditional pricing on options, configurable per product, etc), so I am doing some funky copying of CCK values back and forth on hook_form, and an extra _submit function to get it to work the way I want, but this should get you started. I figured out what all needed to be edited by putting a

<?php
drupal_set_message
('<pre>'.var_export($form,TRUE).'</pre>');
?>

in the hook_form_alter function.

As a side-note (but still related, I think) I'd like to realize my dream ecommerce solution, based on these ideas (use CCK for as much as possible, make cart more of a "glue" layer, rather then the main thing, do everything with cck/views/triggers/actions, so you can model your own cart format/flow using standard drupal tools, etc) and would love any advice from e-commerce / ubercart contributors. My target is D6, which appears to make alot of these sort of things a bit easier (triggers/actions in core, rather then requiring workflow-ng)

essax's picture
Offline
Joined: 04/07/2008
Juice: 2
Re: hook_form_alter()

thank you konsumer for your post.

Since not everbody is familiar with the hook-form-alter() function, here a tutorial :
http://www.hiveminds.co.uk/node/3109.

And here just a stupid question from a newbie. If the product node do not meet our needs, can we just replace it ? (don't shoot please)

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15450
Re: Re: hook_form_alter()

Not sure what needs it wouldn't meet, but it can't be replaced anyways b/c of the way the code looks for product information.

domignon's picture
Offline
Joined: 01/10/2011
Juice: 12
Try this...

let's say you've got an extra CCK field called 'field_product_made_in'.To display it under your product information fieldset you can use the form_alter fx this way :
In your Module file :

function your_module_form_alter(&$form, &$form_state, $form_id) {
// Get the right form
if($form_id = 'uc_product'){
// Pass the field by reference to a variable in the [base] array which is the root of all fields under
// the product information fieldset
$form['base']['field_product_made_in'] = &$form['field_product_made_in'];
}
}

Do the same for all your fields but remember that the order in which you assign them to the [base] array "IS" the order in which they appear in the form.
So don't try to re-arrange somehow your fields using Home → Administer → Content management → Product -> Manage Field afterward...you can be surprised.

sigsby@drupal.org's picture
Offline
Joined: 05/09/2008
Juice: 2
Drupal formfiler module as an alternative

Just for anyone else who stumbles on this thread...

I've recently the formfilter module and it seems to work quite well. It allows you to hide form elements for every form through the UI, instead of creating a module just to use hook_form_alter. Since each product class is a different node type, each will have it's own form which can be controlled by formfilter. Not what you need if your doing any heavy modifications to forms, but great for just hiding a few fields.

http://drupal.org/project/formfilter

nand's picture
Offline
Joined: 09/16/2008
Juice: 2
A website where people can buy information

I want to sell content on my site. There will be a sampler of information, and then people have to buy information.

How can do this.
Please help.

Thanks& God Bless!
Nand

marcuslondon's picture
Offline
Joined: 07/29/2009
Juice: 2
Product Installation service as extra

I would like to add the option of installation to products as an extra service, would it be possible to add it during checkout similar to shipping?
Thanks

crazycolt's picture
Offline
Joined: 09/01/2009
Juice: 18
Re: Product Installation service as extra

As a newbie to Ubercart I do experience the same problems as above. I have added a filed to a product. When entering the product the field is displayed there and I can enter data.

The problem is how to get that specific field displayed on the cart.

Stutzer's picture
Offline
Joined: 09/03/2009
Juice: 24
Hi, guys! Please tell me how

Hi, guys!

Please tell me how to integrate my_module content type (not cck) with ubercart functionality (add to chart button, prics etc.)
Is it real? Or ubercart can work with only content types created via admin panel?

jevous's picture
Offline
Joined: 08/03/2011
Juice: 14
How to retrieve info from the cck field

I think the two functions envolved for the product grid are:
theme_uc_catalog_product_grid --> uc_catalog.module , and
uc_catalog_grid_settings_form --> uc_catalog.admin.inc

So the question is how to retrieve information from the cck field within this two functions...

mahitha's picture
Offline
Administrator
Joined: 11/03/2009
Juice: 538
Re: How to retrieve info from the cck field

node _load($nid) does not retreive the cck fields so add below in your theme_uc_catalog_product_grid.

$node = node_load($nid);
print $node->field_myfield[0]['value'];
jjkktr's picture
Offline
Joined: 09/06/2011
Juice: 13
Re: Adding extra fields to the product

Any body have idea about how to add additional fields (image, description etc) for catloge (Product) listing page?

amcoms's picture
Offline
Joined: 04/04/2012
Juice: 93
stock field

what about the stock field that already exists and yet it does not get an option to be displayed?

amcoms's picture
Offline
Joined: 04/04/2012
Juice: 93
stock field

what about the stock field that already exists and yet it does not get an option to be displayed?

DCWD's picture
Offline
Joined: 12/29/2011
Juice: 8
Out of Date?

Hi,

Seems that this CCK module is out of date because apparently a lot of the CCK is now included in the core Drupal 7. Also the latest version of Ubercart does not have CCK as a recommended include. So I started looking into the core drupal fields but I can't seem to figure out how to add these newly created fields to my products or to my product classes. Can someone help me out here?

Also, a note to the developers, it would be a great idea that if you want to continue growing your user base that you release some updated documentation. Please!?!

DCWD's picture
Offline
Joined: 12/29/2011
Juice: 8
Solution

For those interested, I dug a bit deeper and found that you can add fields to a content type in Drupal. I am completely new to Drupal so all of this is a little overwhelming but if you're also stuck to do so all you have to do is go to Administration » Structure » Content types and in there you'll see that you can edit the fields for a particular content type such as "Product" or any other content types you may have.