VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: kostianev on October 09, 2017, 16:57:36 PM

Title: How to modify the in stock info for product
Post by: kostianev on October 09, 2017, 16:57:36 PM
Dear, I have custom template and want to integrate the In stock level, but only to show that the product is In stock, I need to hide the quantity.

I use this: <?php echo jtext::_('COM_VIRTUEMART_STOCK_AMOUNT');?>: <?php echo $this->product->product_in_stock; ?>
Now is displaying "In stock: 20" I need only to show the text "In Stock"
Title: Re: How to modify the in stock info for product
Post by: GJC Web Design on October 09, 2017, 23:50:13 PM
<?php
if($this->product->product_in_stock > 0){
echo JTEXT::_('COM_VIRTUEMART_STOCK_AMOUNT');
}
?>
Title: Re: How to modify the in stock info for product
Post by: kostianev on October 10, 2017, 08:22:00 AM
Perfect, this working for me. Can you tell me, if you know - how can I make the code, when the product is not in stock with If / Else function to display other div class with red text Out of stock? Because now I have green div for In Stock level and when is out of stock is displayed in additional without div in red for example?
Title: Re: How to modify the in stock info for product
Post by: kostianev on September 17, 2018, 14:24:24 PM
Can someone tell me how to make this code working in Category View?

<?php 
if($this->product->product_in_stock 0){
echo 
JTEXT::_('COM_VIRTUEMART_STOCK_AMOUNT');
}
?>


This code is working and show IN STOCK inside the product in the Product Details Page, but not working in Category view page?
I have another code, which is working fine inside the product and in the Category page like this:

<?php if (isset($productItems->productOutOfStock)) : ?>
<?php if (($productItems->productOutOfStock->product_in_stock $productItems->productOutOfStock->product_ordered) < 1) : ?>
<?php echo JText::_('COM_VIRTUEMART_CART_OUTOFSTOCK'); ?>
<?php endif; ?>
<?php endif; ?>


This code is working, but please can you help me with the IN STOCK code to work in the category page view?
Title: Re: How to modify the in stock info for product
Post by: GJC Web Design on September 17, 2018, 15:17:55 PM
always use

if($product->product_in_stock > 0){

in cats views i.e. not $this
Title: Re: How to modify the in stock info for product
Post by: Studio 42 on September 18, 2018, 17:16:46 PM
Because Virtuemart have reserved/booked stock, i always use
if($product->product_in_stock > $product->product_ordered) {
/* your code here when you have stock */
}


In product details
if($this->product->product_in_stock > $this->product->product_ordered) {
/* your code here when you have stock */
}
Title: Re: How to modify the in stock info for product
Post by: w360 on April 16, 2020, 09:13:37 AM
I know this is a really old post but thanx for the answer here it really made my day a lot easier!