News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Availability field for out of stock products [BUG FIX]

Started by OpenGlobal, May 21, 2012, 22:19:18 PM

Previous topic - Next topic

OpenGlobal

It has been mentioned in other threads that the out of stock option "Products Out of Stock are orderable, and the field 'Availability' below is displayed" does absolutely nothing.

I can confirm this bug and I've found the bit of code causing the problem. In /components/com_virtuemart/views/productdetails/tmpl/default.php the block that handles this "Availability" field is as follows:


<?php
// Availability Image
/* TO DO add width and height to the image */
if (!empty($this->product->product_availability)) {
    $stockhandle VmConfig::get('stockhandle''none');
    if ($stockhandle == 'risetime' and ($this->product->product_in_stock $this->product->product_ordered) < 1) {
?>
<div class="availability">
    <?php echo 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')); ?>
</div>
    <?php } else {
?>

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



But the "if" blocks are in completely the wrong order. The code should be as follows:


<?php
// Availability Image
$stockhandle VmConfig::get('stockhandle''none');
if ($stockhandle == 'risetime' and ($this->product->product_in_stock $this->product->product_ordered) < 1) {
?>
<div class="availability">
    <?php echo 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')); ?>
</div>
    <?php
} else if (!empty($this->product->product_availability)) {
?>

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



This allows the config availability image to be displayed if the product is out of stock, and if the product is in stock, the product availability image is shown instead (if specified).

However, the config screen says that the "text" should be shown if an image is not selected. So, this code block should really be like this:

<?php
// Availability Image
$stockhandle VmConfig::get('stockhandle''none');
if ($stockhandle == 'risetime' and ($this->product->product_in_stock $this->product->product_ordered) < 1) {
?>
<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($this->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/' $this->product->product_availability$this->product->product_availability, array('class' => 'availability')) : $this->product->product_availability?>
</div>
<?php
}
?>



The first bug fixes are essential really. In my opinion the second lot of changes are less urgent, but still required due to the wording in the Virtuemart backend.

Any thoughts?

OpenGlobal

OpenGlobal

Any chance this could make it into the next release?

OpenGlobal

OpenGlobal


inopia

Openglobal, this fix helps me a lot. Thank you very much.

OpenGlobal