News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

How can I display current stock as a number?

Started by rdh8, May 01, 2012, 19:52:24 PM

Previous topic - Next topic

rdh8

VM2 displays an image vmicon vm2-normal.
I want to remove this and put the number in stock.
I see the php file they are using the variable $product.
How do I know what values I can use of that?
In the script they use $product->stock->stock-level
Is there a value in $product that has the quantity in stock?

Thanks,
Robert

PRO

$product->    is for category page.

$this->product     is for category page.

http://forum.virtuemart.net/index.php?topic=97744.0

http://forum.virtuemart.net/index.php?topic=92756.0

whichever you want, the answer is in those 2 threads

rdh8


giupi

#3
Hello BanquetTables.pro,
Hello rdh8,

I read the two posts both for category and details view, but I did not understand where to put the code.

For category view, I managed (even if I don't know how...) to show availability number...

But for details I didn't..

I already have a template override, and in /templates/gk_boutique/html/com_virtuemart/productdetails/ I edited default.php but I really can't find a place where to put <?php echo $this->product->product_in_stock ?>

Maybe somewhere in this part?

<?php
// Availability Image
/* TO DO add width and height to the image */
if (!empty($this->product->product_availability)) {
    $stockhandle VmConfig::get('stockhandle''none');
    if ($stockhandle == 'risetime' and ($this->product->product_in_stock $this->product->product_ordered) < 1) {
?>
<div class="availability">
    <?php echo JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' VmConfig::get('rised_availability''7d.gif'), VmConfig::get('rised_availability''7d.gif'), array('class' => 'availability')); ?>
</div>
    <?php } else {
?>

<div class="availability">
<?php echo JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' $this->product->product_availability$this->product->product_availability, array('class' => 'availability')); ?>
</div>
<?php
    }
}
?>


But nothing happens, also I got some error

I only would like that somewhere in details page could appear: "Availability: xx"

Will you be so kind to help me?

Thank you



PRO


giupi , are you wanting to NOT have regular availability, and to show

Availability: 20 In Stock?

I dont understand

giupi

Hello,

thanks. Yes I would like that in product details I could see somewhere (near the price) Availability: nn (where nn is the number of the items of that specific product I have in stock).

If I could also see the same number even in the module (latest product, featured etc..) would be for me the best  ;D

Thanks in advance

PRO

remove all of this
<?php
      // Availability Image
      /* TO DO add width and height to the image */
      if (!empty($this->product->product_availability)) {
          $stockhandle = VmConfig::get('stockhandle', 'none');
          if ($stockhandle == 'risetime' and ($this->product->product_in_stock - $this->product->product_ordered) < 1) {
         ?>   <div class="availability">
             <?php echo JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . VmConfig::get('rised_availability', '7d.gif'), VmConfig::get('rised_availability', '7d.gif'), array('class' => 'availability')); ?>
         </div>
          <?php } else {
         ?>
         <div class="availability">
         <?php echo JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . $this->product->product_availability, $this->product->product_availability, array('class' => 'availability')); ?>
         </div>
         <?php
          }
      }
      ?>



and use this

<?php echo 'Availability: '.$this->product->product_in_stock ?>


MAKE sure to backup all files before trying stuff like this

ivus

#7
try this:


<?php if (!VmConfig::get('use_as_catalog') and !(VmConfig::get('stockhandle','none')=='none') && (VmConfig::get 'display_stock')) ) : ?>
  <?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP') .' '$this->product->product_in_stock $this->product->product_ordered?>
<?php endif; ?>



This takes into account products that have been ordered, not just the available stock.

notice:
$this->product->product_in_stock - $this->product->product_ordered

so you may have 50 items in stock 14 items ordered.

This line says 50 - 14 = 36... so display 36 items in stock, otherwise it will always 50 items available.



brilliantimpact

I am using child-variants of my products.  Is there a way to show their inventory level?

ironlion37

Phew. May I suggest that showing the available stock as a number be a default option in the admin?