For images, I don't think this is the right way...

Joined: 06/30/2009
Juice: 33

For the image part, at least, you should use api instead of managing pathes by yourself (which is non only ugly but dangerous : what if you change your imagecache preset? or your filesystem architecture?).

For instance, that's my version (I think the good way is to do it entirely with a theme function, but it's easier to begin this way) :

<!-- Start Product  -->

<!-- Start Prices section -->
<?php
       
// maybe there's a better way to do this part, using theme functions
        // but I've only found individual formatting, with "theme_uc_product_price" function
        // here I use Ubercart Discounts (Alternative)
       
$sell_price=$node->sell_price;
       
$reduced_price=$node->field_product_reduced[0]["discounted_price"];
       
$codeless_discount=$node->field_product_codeless[0]["codeless_discounts"];
       
        if (
$reduced_price){
            print
'<div class="product-info product display">';
            print
'<span class="uc-price-product uc-price-display uc-price original-sell-price">'.t("Original price")." : ".uc_currency_format($sell_price).'</span>';
            print
'<span class="uc-price-product uc-price-display uc-price ">'.$codeless_discount." : ".$reduced_price.'</span>';
            print
'</div>';
        }else{
            print
'<div class="product-info product display">';
            print
'<span class="uc-price-product uc-price-display uc-price">'.uc_currency_format($sell_price).'</span>';
            print
'</div>';
        }
       
// Feel free to add other prices here
       
?>

<!-- End Prices section -->

<!-- Start Main informations -->
<?php
       
// product title
       
print "<h2>$title</h2>";
       
// product description
        // if you want to customize how your fields are rendered, use $node->content['YOUR_FIELD_NAME'][0]['#view'];
       
print $node->content['body']['#value'];
       
?>

<!-- End Main informations -->

<!-- Start Images section -->
<?php
       
// if you need a more advanced customization, override the themeable "theme_uc_product_image" function (uc_product.module)
       
if ($node->content['image']['#access']==1)  print $node->content['image']["#value"];
       
?>

<!-- End Images section -->

<!-- Start Weight section -->
<?php
       
// again, if you need a more advanced customization, override the themeable "theme_uc_product_dimensions" function (uc_product.module)
       
if ($node->content['weight']['#access']==1)  print $node->content['weight']["#value"];
       
?>

<!-- End Weight section -->

<!-- Start Dimensions section -->
<?php
       
// again, if you need a more advanced customization, override the themeable "theme_uc_product_dimensions" function (uc_product.module)
       
if ($node->content['dimensions']['#access']==1)  print $node->content['dimensions']["#value"];
       
?>

<!-- End Dimensions section -->

<!-- Start Button section -->
<?php
       
// there's a themable function theme_uc_product_add_to_cart, and I think you still can alter uc_product_add_to_cart_form function
       
print $node->content['add_to_cart']["#value"];
       
?>

<!-- End Button section -->

<!-- End Product  -->

Nifty Products Tutorial Part 1 By: mykz- (132 replies) Wed, 03/19/2008 - 19:04