VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: thefbi on July 02, 2020, 11:15:58 AM

Title: Availability field in custom template
Post by: thefbi on July 02, 2020, 11:15:58 AM
Hello,
i need the availability field for products out of stock.

I try to add this code (find in the sublayout) in my template :
<?php echo (file_exists(JPATH_BASE '/' 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')); ?>

It work, but... Only with the general parameters and it show on ALL product, not only when out of stock.
If somebody can tell me the right code i have to put in my template to make it work ?

Regards,

VM 3.8.4 10335
Joomla 3.9.19
Title: Re: Availability field in custom template
Post by: pinochico on July 02, 2020, 12:43:42 PM
What do you want with this?

Change template, add labels, show info about discontinued.... ?
Title: Re: Availability field in custom template
Post by: thefbi on July 02, 2020, 13:21:46 PM
If i use the protostar template, when a product is out of stock, i can have an image i define in general config or per product, to say for example "3-4 days" as shipping delay.
With my custom template, this field dos not appear, so i want to put manually in the code. So i need the correct syntax to call this field if a product is not in stock.
See attachment, with protostar and my template.

Title: Re: Availability field in custom template
Post by: pinochico on July 02, 2020, 15:44:04 PM
Look at the sublayout stockhandle.php

There is all codes. In our template we use override and change as we wish (we use info from ERP and then change code for this).
Title: Re: Availability field in custom template
Post by: thefbi on July 03, 2020, 10:20:00 AM
Yes, that what i did. But even with copy/past the whole code into my template, i have the information of all products...
And i cant override the general information, and the info is on all product, even if in stock...

So i dont understand...
Title: Re: Availability field in custom template
Post by: thefbi on July 03, 2020, 11:12:16 AM
I got it !

I only have to put this code in my template :
<?php

echo shopFunctionsF::renderVmSubLayout('stockhandle',array('product'=>$this->product));

?>


And now it work fine.