News:

Support the VirtueMart project and become a member

Main Menu

VM2 availability image on category page

Started by trixyD, October 25, 2012, 14:57:12 PM

Previous topic - Next topic

trixyD

Hi guys,

(Go easy on me I'm new)

I've recently come back to Joomla/Virtuemart after a prolonged break and I haven't really used it since it was Mambo/phpShop so I have a quick question.
I'm currently running Joomla 2.5.6 and Virtuemart 2.0.8

I'm looking to add the availability image located on the product flypage, the one in the directory /templates/mytemplate/images/availability to the category page under each product.
Now I know I can use the stock control that's already on the back end to sort of do this. The problem I have though is most of the product on our new site is actually drop shipped from various manufacturers so an accurate stock control method is almost impossible.

I'm struggling to figure it out and PHP isn't really my strong point, can someone please point me in the right direction?






trixyD


bytelord

Hello,

Didn't understand it correctly, could you explain what exactly you wanna do?

PS: Also consider to upgrade to 2.0.12f (backup first)

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

trixyD

Hi bytelord,

Thanks for the response. I'll try to be more explicit for you.

On the back end when adding a product there is the facility on the product status tab to use an availability image to provide the lead time on a product, these images are displayed on each individual product page, but I also want to display the image under each product on the category page as well, so the customer can see the lead time for the product whilst browsing the category page. Does that help?

The images in question are the standard availabilty images located in /templates/yourtemplatedirectory/images/availability.

Oh and I will be updating things before I go too much further, not to worry.




bytelord

#4
Hello,

I read it fast, the title only was very clear, heh :)

The following is for category view as you requested. If are using template overrides you have to edit the file your_joomla_folder/templates/your_template_folder/html/com_virtuemart/category/default.php after line 261 (i placed after the stock level image...the line refers to default template view in version 2012f). Place the following code:

<?php // Availability Image for Category page
$stockhandle = VmConfig::get('stockhandle', 'none');
if (($product->product_in_stock - $product->product_ordered) < 1) {
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
}
}
?>


If you are not using template overrides you could create an override for that one by copying the file:
your_joomla_folder\components\com_virtuemart\views\category\tmpl\default.php

to

your_joomla_folder/templates/your_template_folder/html/com_virtuemart/category/default.php

Edit the file and paste that code.

Also Please read some usefull posts regarding template overrides and vm product/category fields:

Product page fields: http://forum.virtuemart.net/index.php?topic=92756.0
Category page fields: http://forum.virtuemart.net/index.php?topic=97744.0
$this vs $product explained here: http://forum.virtuemart.net/index.php?topic=100696.0

Template overrides: http://forum.virtuemart.net/index.php?topic=98505.0
Template System http://dev.virtuemart.net/projects/virtuemart/wiki/Hints_for_the_use_of_the_template_system

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

lostmail

I inserted the availability field in productdetails/tmlp/default.php

The image of the availability (delivery time) appears in each product detail page - OK

But if a product is realy out of stock - that image does not change or go away.....

What code can i insert to hide the availibility image if a product is out of stock ?

Joomla 3.x | VirtueMart 4.0.12 107771 | HORME3 PRO 1.9.6 / 2.0
VirtueMart 4.2.4 | Joomla 4.4.1 | PHP 8.1 | Vp_neoteric 1.3