Post by opengroupbuy » Fri Apr 17, 2009 10:30 pm

I'd like to echo out the stock available (or backordered) on the product information page. Is there already a variable with the amount (including negative values) available in the template?

My way to do it was modify \catalog\controller\product\product.php:

Code: Select all

$this->data['stock'] = ($product_info['quantity'] > 0)? $this->language->get('text_instock') : $product_info['stock'];
$this->data['quantity']=$product_info['quantity'];//added this line
$this->data['model'] = $product_info['model'];
I added member 'quantity' to the data array, and gave it the value from $product_info['quantity']. $product_info['quantity'] seems to have the values I need, both positive and negative.

Then I slightly modified the template file \catalog\view\theme\default\template\product\product.tpl:

Code: Select all

        <tr>
          <td><b><?php echo $text_availability; ?></b></td>
          <td><?php if((int)$quantity>0){echo $quantity." available now";}else{echo "<font color=red>".abs((int)$quantity)." backordered</font>";} ?></td> <!--modified this line-->
        </tr>
        <tr>
This gives something like the image below. There's still more tweaking to do. I'd prefer to keep the text availability description, and add a line for quantity.

Image

Is there already a template variable for quantity available that I didn't see? It would be great to have this functionality in the release (I can submit a patch).

Newbie

Posts

Joined
Fri Apr 17, 2009 8:15 pm
Who is online

Users browsing this forum: No registered users and 4 guests