Hi,
I use VM VirtueMart 3.8.7 10378
Joomla 3.9.24 and VP Merchant template.
What I need is to show the availability text from the product status, in every product page.
In the file of my layout
html / com_virtuemart / sublayouts / stockhandle.php
I had changed
if (($product->product_in_stock - $product->product_ordered) < 1)
to this
if (($product->product_in_stock - $product->product_ordered) > 1)
The whole stockhandle.php code is this
<?php
/**
*---------------------------------------------------------------------------------------
* @package VP Merchant Template for Joomla!
*---------------------------------------------------------------------------------------
* @copyright Copyright (C) 2012-2020 VirtuePlanet Services LLP. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @authors Abhishek Das
* @email info@virtueplanet.com
* @link https://www.virtueplanet.com
*---------------------------------------------------------------------------------------
*/
defined('_JEXEC') or die('Restricted access');
$product = $viewData['product'];
$stockhandle = VmConfig::get('stockhandle', 'none');
$product_available_date = substr($product->product_available_date, 0, 10);
$current_date = date("Y-m-d");
if (($product->product_in_stock - $product->product_ordered) > 1)
{
if ($product_available_date != '0000-00-00' and $current_date < $product_available_date)
{ ?>
<div class="availability">
<?php echo vmText::_('COM_VIRTUEMART_PRODUCT_AVAILABLE_DATE') .': '. JHtml::_('date', $product->product_available_date, vmText::_('DATE_FORMAT_LC4')); ?>
</div>
<?php
}
elseif ($stockhandle == 'risetime' and VmConfig::get('rised_availability') and empty($product->product_availability))
{ ?>
<div class="availability">
<?php echo (file_exists(JPATH_BASE . DS . VmConfig::get('assets_general_path') . 'images/availability/' . VmConfig::get('rised_availability'))) ? 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')) : vmText::_(VmConfig::get('rised_availability')); ?>
</div>
<?php
}
elseif (!empty($product->product_availability))
{ ?>
<div class="availability">
<?php echo (file_exists(JPATH_BASE . DS . VmConfig::get('assets_general_path') . 'images/availability/' . $product->product_availability)) ? JHtml::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . $product->product_availability, $product->product_availability, array('class' => 'availability')) : vmText::_($product->product_availability); ?>
</div>
<?php
}
}
else if ($product_available_date != '0000-00-00' and $current_date < $product_available_date)
{ ?>
<div class="availability">
<?php echo vmText::_('COM_VIRTUEMART_PRODUCT_AVAILABLE_DATE') .': '. JHtml::_('date', $product->product_available_date, vmText::_('DATE_FORMAT_LC4')); ?>
</div>
<?php
} ?>
As I remember, it was working and the availability text was visible, for all my products.
Now shows the text "In Stock".
Even if I delete my override stockhandle.php, the availability text in the status of the product, is not shown.
The productdetails default page has this code
<div class="product-stock-cont">
<?php $stock = VPFrameworkVM::getStockText($this->product); ?>
<span class="<?php echo $stock->class ?> hasTooltip" title="<?php echo $stock->tip ?>"><?php echo $stock->text ?></span>
</div>
So what I need basically is to load the availability text in here <?php echo $stock->text ?>
Thank you
VPFrameworkVM is sounds like VirtuePlanet template product.
Are you tryied to ask bimbo first?
Hi idor,
"Now shows the text "In Stock"
This is normal behavior, if the stock check is correct
If the stock result (stock - orders & reserved) reach the minimum stock alert of the product it will be:
"Only X left"
If stock is zero:
"Out of stock" or nothing but the "Keep me inform button" in place of the add to cart.
And depend of the setting that you've choose in VM admin on the "Front Store" tab at section "Action when a product is out of stock"
BUT if you set an availability date in future on the product, so the availability date will appear in the top-right position.
That's the code that you're talking about that is call by this one in /productdetails/default.php in top-right section:
<?php echo shopFunctionsF::renderVmSubLayout('stockhandle', array('product' => $this->product)); ?>
the last part of the code handle this:
else if ($product_available_date != '0000-00-00' and $current_date < $product_available_date)
Unless you do not choose an image for the availability
But ask to Jumbo on the VP Forum for more support
Yes I send to virtueplanet support first. They said they didn´t change anything lately in the template.
I am sure it was working with the modification I ´ve done on stochandle.php so I thought maybe something changed on VM.
I tested with protostar also.
Protostar displays the availability text for products out of stock.
And if I change
if (($product->product_in_stock - $product->product_ordered) < 1) {
to
if (($product->product_in_stock - $product->product_ordered) > 1) {
I get the availability text for products IN Stock, in my case will be all of my products..
Unfortunatelly changing back to VP Merchant shows always the text "In Stock" not the availability text in product´s status.
BTW I also send image with the configurations of VM. It was like that when it was working. Is it right?
Thank you!
seems ok
I use the 4th for my own purpose.
I will try to achieve what you try to.
But did you try to simply escape the if condition just for the proof of concept ?
//if (($product->product_in_stock - $product->product_ordered) > 0) {
and at the end
<?php
//} ?>
Quote from: sirius on January 23, 2021, 14:10:37 PM
Hi idor,
"Now shows the text "In Stock"
This is normal behavior, if the stock check is correct
If the stock result (stock - orders & reserved) reach the minimum stock alert of the product it will be:
"Only X left"
If stock is zero:
"Out of stock" or nothing but the "Keep me inform button" in place of the add to cart.
And depend of the setting that you've choose in VM admin on the "Front Store" tab at section "Action when a product is out of stock"
BUT if you set an availability date in future on the product, so the availability date will appear in the top-right position.
That's the code that you're talking about that is call by this one in /productdetails/default.php in top-right section:
<?php echo shopFunctionsF::renderVmSubLayout('stockhandle', array('product' => $this->product)); ?>
the last part of the code handle this:
else if ($product_available_date != '0000-00-00' and $current_date < $product_available_date)
Unless you do not choose an image for the availability
But ask to Jumbo on the VP Forum for more support
Hi Sirius,
Thank you for your explanation about the stock functionality!
Finally it worked and this
<?php echo shopFunctionsF::renderVmSubLayout('stockhandle', array('product' => $this->product)); ?>
did the trick!
Oh ok glad to read that ;)
your welcome
(don't forget to put the solved icon on the title)
DONE! ;)