Welcome, Guest
Username: Password: Remember me
Use this Category for your support questions about Virtuemart Template - MaterialMart (SKU# FLEX-00020)

TOPIC: View product availability in the product category

View product availability in the product category 5 years 6 months ago #15695

Hello,

how can I set up a view of availability in the product category?

Thank you Milan
Attachments:
The administrator has disabled public write access.

View product availability in the product category 5 years 6 months ago #15700

Hi Puchoň,

Yes it is totally possible. But it requires a little bit of customization to some php codes. If you follow my instructions, you will get what you want.

NOTE: I am giving you the instructions only for the defaul-layout (v1) & grid-view, but the procedure is exactly the same for other views or layout v2.

1- Open this PHP file:
ROOT/templates/YOUR_TEMPLATE/html/com_virtuemart/sublayouts/stockhandle.php

clear that file and copy-paste the blow lines instead:
<?php
/*------------------------------------------------------------------------
 # Virtuemart 3 Template - MaterialMart
 # ------------------------------------------------------------------------
 # Copyright (C) 2009-2017 Flexible Web Design. All Rights Reserved.
 # @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3
 # Author: Flexible Web Design
 # Website: http://www.flexiblewebdesign.com
 # Email: [email protected]
 -------------------------------------------------------------------------*/
 
$product = $viewData['product'];
$textAlign = isset($viewData['textAlign']) ? $viewData['textAlign'] : 'text-right';
 
// Availability
$lang = JFactory::getLanguage();
$app		=	JFactory::getApplication('site');
$template	=	$app->getTemplate(); 
$imgFolder = JURI::base(true).'/templates/'.$template.'/html/com_virtuemart/assets/images/availability/'. $lang->getTag() .'/'; 
 
$stockhandle = VmConfig::get('stockhandle', 'none');
$product_available_date = substr($product->product_available_date,0,10);
$current_date = date("Y-m-d");
$image = str_replace('.gif', '.png', $product->product_availability);
 
if (($product->product_in_stock - $product->product_ordered) < 1) {
		if ($product_available_date != '0000-00-00' and $current_date < $product_available_date) { ?>	
 
        <div class="col flexAvailability <?php echo $textAlign;?>">
            <?php echo vmText::_('COM_VIRTUEMART_PRODUCT_AVAILABLE_DATE') .': '. JHtml::_('date', $product->product_available_date, vmText::_('DATE_FORMAT_LC4')); ?>
        </div>
 
	<?php } else if ($stockhandle == 'risetime' and VmConfig::get('rised_availability')) { ?>
 
    	<div class="col flexAvailability <?php echo $textAlign;?>">
			<?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 ($stockhandle == 'disableadd') {?>
 
		<div class="col flexAvailability <?php echo $textAlign;?>">
			 <img src="<?php echo $imgFolder?>out_of_stock.png" alt="Out Of Stock">
		</div>
 
	<?php } ?>
 
<?php } else if ($product_available_date != '0000-00-00' and $current_date < $product_available_date) { ?>
 
	<div class="col flexAvailability <?php echo $textAlign;?>">
		<?php echo JText::_('TPL_FLEXIBLE_PRODUCT_AVAILABLE_DATE') .': <strong>'. JHtml::_('date', $product->product_available_date, vmText::_('DATE_FORMAT_LC4')); ?></strong>
	</div>
 
<?php } else if (!empty($product->product_availability)) { ?>
 
    <div class="col flexAvailability <?php echo $textAlign;?>">
	  <img src="<?php echo $imgFolder.$image?>" alt="<?php echo $image?>">
 
	  <?php
	  //echo '<img src="' . $availabilityImgFolder .'/1-2m.png">';
	  //echo vmText::_($product->product_availability);
	   //echo $availabilityImgFolder. $product->product_availability, $product->product_availability, array('class' => '')) : vmText::_($product->product_availability); ?>
    </div>
 
<?php } ?>

2- Open this PHP file:
ROOT/templates/YOUR_TEMPLATE/html/com_virtuemart/sublayouts/pro-cat-grid.php

and add this line:
<?php echo shopFunctionsF::renderVmSubLayout('stockhandle', array('product' => $product, 'textAlign'=>'text-center')); ?>

to anywhere where you want to display the availability images. I suppose, above this line is a good place:
<?php if ($params->get('category_grid_prices') or $params->get('category_grid_addtocart')) echo '<hr>'; ?>

so, the result will be:
<?php echo shopFunctionsF::renderVmSubLayout('stockhandle', array('product' => $product, 'textAlign'=>'text-center')); ?>
 
<?php if ($params->get('category_grid_prices') or $params->get('category_grid_addtocart')) echo '<hr>'; ?>

Once you do it, the result in the front-end will be:

Attachment ScreenShot2018-10-10at10.59.05PM.png not found




NOTE: for the other views and version, repeat the 2nd step for the PHP files that starts with: pro-cat-* within the /sublayouts/ folder

Regards
The administrator has disabled public write access.
Time to create page: 0.189 seconds

MaterialMart

for Virtuemart 3

Google's Material Design has finally arrived to Virtuemart

Virtumart Template - MaterialMart Virtumart Template - CleanMart Virtumart Template - CleanMart Virtumart Template - CleanMart

Fully responsive!

Buy Now   |   Live Demo