Author Topic: Availability image in category-Page (products.php) - Virtuemart 3  (Read 1305 times)

ksfbjoern

  • Beginner
  • *
  • Posts: 27
Hello,

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

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

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26372
  • Always on vacation
    • Jenkin Hill Internet
Re: Availability image in category-Page (products.php) - Virtuemart 3
« Reply #1 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.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM3.2.6 on Joomla 3.8.2 PHP 7.0.25

Testing VM3.2.6 on J!4alpha1

astrovest

  • Beginner
  • *
  • Posts: 2
  • A beginner
  • Skype Name: astrovest.ro
Re: Availability image in category-Page (products.php) - Virtuemart 3
« Reply #2 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 :

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

  • Beginner
  • *
  • Posts: 2
  • A beginner
  • Skype Name: astrovest.ro
Re: Availability image in category-Page (products.php) - Virtuemart 3
« Reply #3 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:
Code: [Select]
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:
Code: [Select]
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

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 834
  • VirtueMart Version: VM3 on J3
Re: Availability image in category-Page (products.php) - Virtuemart 3
« Reply #4 on: May 20, 2017, 01:05:18 am »
Code: [Select]
VmConfig::get('rised_availability', 'InStocAV2.gif')
your main config has 3-5d.gif as rised_availability image