Author Topic: How to modify the in stock info for product  (Read 1358 times)

kostianev

  • Jr. Member
  • **
  • Posts: 70
  • Web Developer
    • MOON.bg
  • Skype Name: moonbgltd
  • VirtueMart Version: 3.x
How to modify the in stock info for product
« 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"

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9246
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: How to modify the in stock info for product
« Reply #1 on: October 09, 2017, 23:50:13 pm »
<?php
if($this->product->product_in_stock > 0){
echo JTEXT::_('COM_VIRTUEMART_STOCK_AMOUNT');
}
?>
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

kostianev

  • Jr. Member
  • **
  • Posts: 70
  • Web Developer
    • MOON.bg
  • Skype Name: moonbgltd
  • VirtueMart Version: 3.x
Re: How to modify the in stock info for product
« Reply #2 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?

kostianev

  • Jr. Member
  • **
  • Posts: 70
  • Web Developer
    • MOON.bg
  • Skype Name: moonbgltd
  • VirtueMart Version: 3.x
Re: How to modify the in stock info for product
« Reply #3 on: September 17, 2018, 14:24:24 pm »
Can someone tell me how to make this code working in Category View?

Code: [Select]
<?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:

Code: [Select]
<?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?

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9246
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: How to modify the in stock info for product
« Reply #4 on: September 17, 2018, 15:17:55 pm »
always use

if($product->product_in_stock > 0){

in cats views i.e. not $this
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4076
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: How to modify the in stock info for product
« Reply #5 on: September 18, 2018, 17:16:46 pm »
Because Virtuemart have reserved/booked stock, i always use
Code: [Select]
if($product->product_in_stock > $product->product_ordered) {
 /* your code here when you have stock */
}

In product details
Code: [Select]
if($this->product->product_in_stock > $this->product->product_ordered) {
 /* your code here when you have stock */
}