News:

Support the VirtueMart project and become a member

Main Menu

How to hide quantity in stock

Started by YZF, April 15, 2015, 21:32:10 PM

Previous topic - Next topic

YZF

Does anyone know how to remove the stock quantity on the product detail page so it just says "In stock" or "out of stock" without the quantity being displayed?

Before you mention to uncheck the box that says "Display stock level", we did that; the quantity still shows up (bug?).

We are using VirtueMart 3.0.2 and Joomla 3.3.6.

I found this old link which seems to talk about what I want to do, but the file referred to in the example doesn't exist.
http://forum.virtuemart.net/index.php?topic=80684.0

Any assistance is greatly appreciated.

GJC Web Design

in the default.php somewhere

if($this->product->product_in_stock >0{
echo 'In Stock';
}else{
echo 'Out of Stock';
}
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

YZF

Thank you GJC. I'll give that a try.

YZF

#3
Another question... which default.php file do I edit?

I found one here:
httpdocs/templates/t3_blank/tpls/default.php

There is also another one here:
httpdocs/templates/t3_blank/html/com_virtuemart/virtuemart/default.php

and one here:
httpdocs/templates/t3_blank/html/com_virtuemart/productdetails/default.php

There's more, but you get the idea.

Also, I don't have much experience editing php files. Am I just adding the code to the file, or editing existing code.

GJC Web Design

httpdocs/templates/t3_blank/html/com_virtuemart/productdetails/default.php
adding
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

YZF

Hello again GJC, Thank you for your help so far.

I found the following code on the default.php page:

-------------------------------------------------

            <?php
            // Manufacturer of the Product
            if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) {
              echo  $this->loadTemplate('manufacturer');
            }
            if ($this->product->product_in_stock >=1) {
            echo '<div class="stock"><span class="bold">'.JText::_('DR_AVAILABILITY_NEW').':</span><i class="green">'.JText::_('DR_IN_STOCK_NEW').'</i>&nbsp;<b>'.$this->product->product_in_stock.'&nbsp;'.JText::_('DR_ITEMS_NEW').'</b></div>';
            }else {
            echo '<div class="stock"><span class="bold">'.JText::_('DR_AVAILABILITY_NEW').':</span><i class="red">'.JText::_('DR_OUT_STOCK_NEW').'</i>&nbsp;<b>'.$this->product->product_in_stock.'&nbsp;'.JText::_('DR_ITEMS_NEW').'</b></div>';
            }
            echo '<div class="code"><span class="bold">'.JText::_('DR_PRODUCT_CODE_NEW').':</span>'.$this->product->product_sku.'</div>';
         ?>

-----------------------------------

I am assuming I should add the code after the last </div>'; but before ?>
So code should look like the following:

------------------------------------

            echo '<div class="code"><span class="bold">'.JText::_('DR_PRODUCT_CODE_NEW').':</span>'.$this->product->product_sku.'</div>';
         
if($this->product->product_in_stock >0{
echo 'In Stock';
}else{
echo 'Out of Stock';
}

?>

---------------------------------------
Does that sound right?

GJC Web Design

should work -- but no test like trying..  ;)
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

YZF

I tried.... nothing happened.  :-\

At least the site didn't break, but nothing changed.

Maybe I pasted the code in the wrong place?

YZF

I tried something new (experimenting... )

Original code:

            if ($this->product->product_in_stock >=1) {
            echo '<div class="stock"><span class="bold">'.JText::_('DR_AVAILABILITY_NEW').':</span><i class="green">'.JText::_('DR_IN_STOCK_NEW').'</i>&nbsp;<b>'.$this->product->product_in_stock.'&nbsp;'.JText::_('DR_ITEMS_NEW').'</b></div>';
            }else {
            echo '<div class="stock"><span class="bold">'.JText::_('DR_AVAILABILITY_NEW').':</span><i class="red">'.JText::_('DR_OUT_STOCK_NEW').'</i>&nbsp;<b>'.$this->product->product_in_stock.'&nbsp;'.JText::_('DR_ITEMS_NEW').'</b></div>';
            }

-------------------

Modified Code:

            if ($this->product->product_in_stock >=1) {
            echo '<div class="stock"><span class="bold">'.JText::_('DR_AVAILABILITY_NEW').':</span><i class="green">'.JText::_('DR_IN_STOCK_NEW').'</i>&nbsp;</div>';
            }else {
            echo '<div class="stock"><span class="bold">'.JText::_('DR_AVAILABILITY_NEW').':</span><i class="red">'.JText::_('DR_OUT_STOCK_NEW').'</i>&nbsp;</div>';
            }

-----------------

I basically removed this part from both sections:
<b>'.$this->product->product_in_stock.'&nbsp;'.JText::_('DR_ITEMS_NEW').'</b>

Result .... nothing changed.

I'm not sure of my next move.

YZF

#9
I found the problem (with help from Frans D). I was modifying default.php. The site was using default2.php

The code above in my last post seems to work.