I tried to theme the uc catalog product grid to show discounted price field

The theme function I used is
function theme_uc_catalog_product_grid($products)

and added a line
$product_table .= '' . uc_currency_format($discounted_price) . '';

but it just show me 0 even there is a discount price.

What is the properly variable to print the discounted price ?

CommentFileSizeAuthor
#8 no discount price.jpg100.3 KBvmed

Comments

adrianmak’s picture

or $product_table .= '' . uc_currency_format($product->$discounted_price) . '';

I got

Fatal error: Cannot access empty property in C:\wamp\www\roundbaby2\sites\all\modules\ubercart\uc_catalog\uc_catalog.module on line 719

I tried to print_r($product) and cannot find a discounted_price and another codeless field in $product object

ryangroe’s picture

The discounted price is always calculated. Use this:
$discounted_price = theme("get_discounted_price", $node);
if ( is_null($discounted_price) )
{
//no discount
}

adrianmak’s picture

I tried your code but nothing print out.

I simplified the code for no checking and print variable no matter is null.

 $discounted_price = theme("get_discounted_price", $node);
 print $discounted_price;

nothing output even the product has discounted.

ryangroe’s picture

This seemed to work for me:

function phptemplate_uc_catalog_product_grid($products)
{
  $s = "";

  foreach ($products as $nid)
  {
    $product = node_load($nid);
    $discounted_price = theme("get_discounted_price", $product);
    $s .= $nid . ":" . $discounted_price . "<br/>";
  }

  return $s;
}

Can you drop this in and see if it works? If it doesn't we debug further to figure out why.

adrianmak’s picture

ryangroe,

code works now.

I'm very appreciate your efforts made on this module.

ryangroe’s picture

I'm happy to help :)

ryangroe’s picture

Status: Active » Closed (fixed)

I'm going to mark this closed. If you have any more problems please re-open it.

vmed’s picture

StatusFileSize
new100.3 KB

hi there,

... i need the discount price in the field prijs ! , any idea how ???, i use the danland theme !

see attached image for my catalog page

thanks
johan