VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: ksfbjoern on November 26, 2014, 17:29:41 PM

Title: Availability image in category-Page (products.php) - Virtuemart 3
Post by: ksfbjoern on November 26, 2014, 17:29:41 PM
Hello,

in Virtuemart 2 i could show the availability image in the category with the following code:

<?php // Availability Image for Category page
$stockhandle = VmConfig::get('stockhandle', 'none');
if (($product->product_in_stock - $product->product_ordered) > 0) {
if ($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')) : VmConfig::get('rised_availability'); ?>
</div>
    <?php
} else if (!empty($product->product_availability)) {
?>

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


In Virtuemart 3 it doesn't works. Any ideas to modify it for Virtuemart 3?

Thanks a lot!

Greetings Björn
Title: Re: Availability image in category-Page (products.php) - Virtuemart 3
Post by: jenkinhill on November 26, 2014, 18:08:36 PM
The availability image displays automatically in the category layout with the default VM3 templates, so either use the default templates or copy the code from there into your override.
Title: Re: Availability image in category-Page (products.php) - Virtuemart 3
Post by: astrovest on May 19, 2017, 18:49:05 PM
Hello everyone.

I have an issue with product availability image and this topic seems like a related thing so I'll ask my question here :)

I have Joomla 3.6.5 and VM 3.0.18

When product stock is under 0 I can easily show whatever image i want for product availability from the product page. However, I want to be able to show a different image when product is in stock, stock level greater than 0. I can't seem to manage that.

I suspect the code responsilbe for showing availability images is this part from com_virtuemart/sublayouts/stockhandle.php :

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_datevmText::_('DATE_FORMAT_LC4')); ?>
</div>
<?php
} else if (
$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
} else if (!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_datevmText::_('DATE_FORMAT_LC4')); ?>
</div>


I tried diferent versions  of if (($product->product_in_stock - $product->product_ordered) > 1) but I can't manage to make it show my image when product is in stock.

Can anyone help?
Title: Re: Availability image in category-Page (products.php) - Virtuemart 3
Post by: astrovest on May 19, 2017, 20:05:22 PM
I did some more testing and i managed to get to a result, but not the one I expected.

I changed this part at the end:
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_datevmText::_('DATE_FORMAT_LC4')); ?>
</div>


With this part:else if (($product->product_in_stock - $product->product_ordered) > 0) {
?> <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''InStocAV2.gif'), VmConfig::get('rised_availability''InStocAV2.gif'), array('class' => 'availability')) : vmText::_(VmConfig::get('rised_availability')); ?>
</div>


Where InStocAV2.gif is the image I want to be shown when the product is in stock. However, the image displayed based on this change is the default 3-5d.gif VM has. I don't understand why, there's no reference in the code of 3-5d.gif  :o
Title: Re: Availability image in category-Page (products.php) - Virtuemart 3
Post by: K&K media production on May 20, 2017, 01:05:18 AM
VmConfig::get('rised_availability', 'InStocAV2.gif')

your main config has 3-5d.gif as rised_availability image