0
votes

I want to change the template of my Ubercart products. More in detail, I want to add the label "From..." in front of each price. But I cannot find the template to do it.

I'm also using theme developer module and this is what I get:

zen_uc_product_price < phptemplate_uc_product_price < theme_uc_product_price

But I cannot find such files.

thanks

2

2 Answers

0
votes

You can also make a node-product.tpl.php file, if so this is the way to get prices:

 <?php
    $context = array(
      'type' => 'product',
      'revision' => 'altered', // using altered to get the bare price with no themeing
      'field' => 'sell_price',
      'subject' => array('node' => $node)
    );
    $dp = uc_price($node->sell_price, $context);
    $context['field'] = 'list_price';
    $lp = uc_price($node->list_price, $context);
    ?>


  <div class="price clear-block <?php if($dp != $lp) print 'discounted'; ?>">
    <?php print 'From: ' . $node->content['display_price']['#value']; ?>
    <?php //print $node->content['list_price']['#value']; ?>
  </div>

This became a bit more than it should be: Use: content['display_price']['#value']; ?>

Unless you want to theme discounted pricing :-)

Just copied out from one of my projects.

Last: you can probably use theme_uc_product_price: you add a function in template.php (Pasting in default implementation from uc_product.module

function zen_uc_product_price($price, $context, $options = array()) {
  $output = '<div class="product-info '. implode(' ', (array)$context['class']) .'">';
  $output .= uc_price($price, $context, $options);
  $output .= '</div>';

  return $output;
}

Inspect the $context variable for when to add the "From" part.

0
votes

To add a prefix or suffix to the price, you can go to /admin/store/settings/store/edit/format