17 replies [Last post]
mkenney's picture
Offline
Joined: 11/10/2011
Juice: 9
Was this information Helpful?

Really struggling , like many others it sounds like, on grasping how to change/develop a product template for Ubercart 3.x. (http://www.ubercart.org/forum/development/3868/nifty_products_tutorial_p...) is a great resource for Ubercart 2.x but seems like it doesn't work with Ubercart 3.x very well.

Does anyone have a basic "node--product.tpl.php" that they would be willing to share. I'm new like many others and a simple functioning example would really help spring board the learning curve.

If this cat has already been skinned, please point me in the right direction and acdcept my apologizes for wasting people's time!!!

Thanks for any help!

Mark

dappi's picture
Offline
Joined: 11/07/2011
Juice: 12
Re: Drupal 7 Ubercart 3.x node--product.tpl.php Basic Example

This would aweseome! I must say that support from ubercart is appaling :/

amcoms's picture
Offline
Joined: 04/04/2012
Juice: 135
appauling 3 years on!

I have just made the exact same view, it is so frustrating.

The funny thing is, people will stop and spend time to justify a free OS system in defence of there being no support!

What a very strange concept. It's free so what you complaining about!

The next part is, hey if you want support there are plenty of developers out there that you can 'hire' to help.

Yes, there are plenty of developers out there, that also do not understand Ubercart3 combined with drupal7 and they screw things up and leave you in a deeper hole!

mpalermo's picture
Offline
Joined: 01/20/2012
Juice: 22
Re: Drupal 7 Ubercart 3.x node--product.tpl.php Basic Example

Looking for help with this also. Did anyone find any useful information for accomplishing this?

Visit us at: http://totaldev.com

rkdarwin13's picture
Offline
Joined: 02/21/2012
Juice: 8
ditto that

I too am looking for a solution here. I'm very, very new to all of this (coming from a CF background) and could use some guidance here. A working example of Drupal 7/UC 3.x of node--product.tpl.php would be wonderfully helpful.

Geva's picture
Offline
Joined: 02/18/2011
Juice: 112
RE: Drupal 7 Ubercart 3.x node--product.tpl.php

hi,

- copy node.tpl.php and rename node--product.tpl.php - if your product type is "product" otherwise node--yourproductname.tpl.php in your theme directory
(node.tpl.php file is too in your theme directory)
- to be replace the following lines, line 102:

      <?php print render($content); ?>

- you have to print the necessary ubercart variables, in required format,
for example:

<?php
 
if ($view_mode == 'teaser')
    print
render($content['uc_product_image']['0']); <!-- in teaser print only the first product image -->
  else
    print
render($content['uc_product_image']); <!-- in full product node view the images style product_image -->
  print(
'<div class="sell">' . $sell_price) . '</div>');
  print
render($content['add_to_cart']);
  print
render($content['body']);
  print(...);
?>

- variables name by drupal devel modul,
...of course, still needs to be formatted in a css file

my drupal 7 + ubercart 3 product (theme based on PSD - test drupal site): http://drupalthemes.gevapc.hu/hu/product/business-psd
and a category list width teasers of the products: http://drupalthemes.gevapc.hu/hu/catalog/9

This will help you?

rkdarwin13's picture
Offline
Joined: 02/21/2012
Juice: 8
A thousand blessings be upon thee!

sweet buttery goodness!

You..... are my hero. This helped, thank you for pointing me in the right direction.

Geva's picture
Offline
Joined: 02/18/2011
Juice: 112
Re: A thousand blessings be upon thee!

good luck Smiling

Juc1's picture
Offline
Joined: 06/05/2011
Juice: 113
sell price field

@ Geva or anyone,

When I create a new product, sell-price is a required field. But this means that a product that has options will display both the sell price field and the options prices as seen here:

http://drupal.org/files/issues/PowerToolUseExample.jpg

or the same problem when products are listed in Views.

This sucks so I want to make the sell-price an optional field (ie so when creating a product I would use the sell-price field when a product has no options but leave it empty for a product that has options).

Can I do this in node--product.tpl.php? I think the answer is no because node--product.tpl.php kicks in after a product node is created but it is really the creating a new product code that I want to get at.

thank you

Geva's picture
Offline
Joined: 02/18/2011
Juice: 112
Re: sell price field

Hi Juc1,
I think, you have 2 different types of products - in their structures.
Set the Product content type:
- sell price value = 0 + attributes;
- you must hide the sell price (as a field of product content type), only attributes visible width their prices

You set a new class of product (Store - Products - Manage Classes and add a class, for example it's name Product2
Set the Product2 content type:
(has no attributes)
- sell price visible as a field in page Structure - Content types - Product2 ---> manage display, Format of sell price Visible

voila Smiling
is it ok?

Juc1's picture
Offline
Joined: 06/05/2011
Juice: 113
Re: sell price field

Hey Geva

Thanks for your help. I think that will work for a node view but not in a View because the choice in Views is to output the sell-price field for all products or for no products.

But I think there is a solution to this -

2 classes of products - options and no options
hide the sell-price in both product classes
create "new-price-field" for only the no-options class
in Views the "new-price-field" will output for the no-options class but not for the options class (because the field doesn't exist)
In both the node and the View, the no-options class will output "new-price-field" and not the sell-price field
In both the node and the View, the options class will output the options prices and not the sell-price field
the sell-price field will not be seen at all by the shopper but behind the scenes will get the relevant price into the cart.

I haven't tried it yet but it sounds good.

By the way it seems that when a product has options they just show up in a View ie without being a field which can be selected or not for the View. This seems strange but I guess it works ok with the above.

Thanks

Juc1's picture
Offline
Joined: 06/05/2011
Juice: 113
Re: Re: sell price field

On second thoughts maybe I don't need separate product classes at all. I could just use the "new-price-field" for the no-options products and leave it empty for the options products then in Views 'hide this field if empty'.

thanks

Geva's picture
Offline
Joined: 02/18/2011
Juice: 112
Re:Re:Re: sell price field

Hi Juc1,
thanks for the additional thoughts, your are right width Views,
Good luck and success in your work,
Geva

squarecandy's picture
Offline
Joined: 01/04/2012
Juice: 20
AMAZING

Thank you so much. This is extremely helpful starting in on my first D7 / UC3 site after a few successful D6 / UC2 sites.
The whole D7 render function is looking to be extremely simple, powerful and great.

In case it helps anyone, I'm removing the add to cart from from my nodes on a ticket sales site after the show is over:

<?php
// hide the add to cart form if the show is over
if ($lastdate_timestamp < time()) hide($content['add_to_cart']);

// add the above before:
print render($content);
?>
amcoms's picture
Offline
Joined: 04/04/2012
Juice: 135
Drupal 7 Ubercart 3.x node--product.tpl.php

I think the main clarification for themeing the product node is what the actual constituent parts of the content are instead of just just $content

DanZ's picture
Offline
Joined: 08/07/2011
Juice: 1738
Geva wrote:- copy
Geva wrote:

- copy node.tpl.php and rename node--product.tpl.php - if your product type is "product" otherwise node--yourproductname.tpl.php in your theme directory
(node.tpl.php file is too in your theme directory)

What exactly is "your theme directory?" There are a lot of theme directories.

Note that I'm using just the basic, unmodified Garland theme that comes with the Drupal core. I don't think I should be putting files in that directory.

Geva's picture
Offline
Joined: 02/18/2011
Juice: 112
DanZ,your are right

DanZ,
your are right (also)
you never copy any files to the default theme directory, for example Garland theme directory in ../themes/
and never modify Garland themes files

you need a sub-theme based by Garland,
the directory of your sub-theme in ../sites/all/themes/
a directory named subgarland for example
details: https://drupal.org/node/225125

your sub-theme directory is the right place your modified tpl.php files

is it ok?

benitezv1ang's picture
Offline
Joined: 01/16/2011
Juice: 39
ubercar 3.0

if you are using Ajax-ify attribute option price selection to update the price total in custom node here is the code. node--product.tpl.php

<p><?php print $title ?></p>

<div class="uc_product_image"> <?php print render($content['uc_product_image']);?> </div>

<div class="uc_product_body"> <?php print render($content['body']);?> </div>

<p><?php print render($content['add_to_cart']); ?></p>
              
<p>Total: <span class="uc-price product-info display-price uc-product-<?php $nid = $node->nid; print $nid; ?>"> <?php print uc_currency_format($node->sell_price); ?> </span></p>