3 replies [Last post]
nadavoid's picture
Offline
Joined: 11/13/2007
Juice: 63

Is there a way to convert only certain nodes to be ubercart products, without changing the content type?

I have an "event" content type, and I would like to make some of these events purchasable. For events that are free (or where purchasing doesn't make sense at all) I don't want to have any ubercart stuff showing, and I don't want the ubercart form fields to be displayed on the node edit form. I guess what would be ideal is a checkbox on the node edit form "Make this node purchasable". Is anything like this possible?

monotaga's picture
Offline
Joined: 12/29/2008
Juice: 11
nadavoid, Did you ever come

nadavoid,

Did you ever come up with a solution for this?

nadavoid's picture
Offline
Joined: 11/13/2007
Juice: 63
Sort of. Although it doesn't

Sort of.

Although it doesn't literally enforce a barrier on ordering a product, it does remove the Add to Cart button/form.

Here's my method. It consists of Views and Panels. Mostly Views.

For a product listing page, I create a view. As one field of the view, I include an add to cart form. I add to my template.php file a preprocess function for the Add to Cart field. In it, I check for whatever property of the node I am interested in, for determining whether the node is purchasable. For my use, I check the price. If it's zero, I unset the content of the field, and the Add to Cart form will not appear in the view. You could check other fields, such as perhaps a custom CCK checkbox "Make purchasable".

For the product detail page, I did a similar thing. I laid out the detail page using a panel. I fill each pane of the panel with elements from a view. I created a view called "product elements" and create a Panel Pane display for each individual element I want to be displayed. Examples would be the title, description, images, additional information, and of course the Add to Cart form. Now since in this case the Add to Cart form is the only thing in its own display, I can use a views filter to show or hide it. That filter can check the price, a cck field, or whatever. It could be that the views preprocess function in the first part could take effect here too, and this views filter may not even be necessary.

Hope that's helpful. Let me know if you would like any further detail. Views preprocessing is a nifty, undocumented, and very useful technique.

-david

codebutcher's picture
Offline
Joined: 09/10/2010
Juice: 15
Re: Sort of. Although it doesn't

Just a thought, why not set to $0.00 and let them add to cart? This way, it helps estimate event attendance. Also a great way to track how people found out about the event.