News:

Looking for documentation? Take a look on our wiki

Main Menu

Availability image in category-Page (products.php) - Virtuemart 3

Started by ksfbjoern, November 26, 2014, 17:29:41 PM

Previous topic - Next topic

ksfbjoern

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

jenkinhill

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.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

astrovest

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?

astrovest

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

K&K media production

VmConfig::get('rised_availability', 'InStocAV2.gif')

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