VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: Hujub on November 15, 2012, 17:58:09 PM

Title: Availability Field
Post by: Hujub on November 15, 2012, 17:58:09 PM
VM2 JOOMLA 2.5

How do you get the availability to show on a product?
When i select in in the back end, no show in the front end?

Many thanks,
Title: Re: Availability Field
Post by: Hujub on November 23, 2012, 13:35:25 PM
Anyone know how to do this???
Title: Re: Availability Field
Post by: bytelord on November 23, 2012, 14:34:36 PM
Hello,

You forgot to mention your VM2 version you are using, just vm 2 is too general, which version? Do you use custom template overrides?

For the availability text/image to work you have to enable the availability and also for each product to select the availability you have. Please make sure you have updated your custom templates if you are using them.

Regards
Title: Re: Availability Field
Post by: Hujub on November 27, 2012, 13:15:57 PM
Quote from: bytelord on November 23, 2012, 14:34:36 PM
Hello,

You forgot to mention your VM2 version you are using, just vm 2 is too general, which version? Do you use custom template overrides?

For the availability text/image to work you have to enable the availability and also for each product to select the availability you have. Please make sure you have updated your custom templates if you are using them.

Regards

Hello Bytelord, thanks for getting back to me,

im using Version 2.0.14
I am using the default template
I have very new to this and am learning as im going...
My site is www.hubjub.co.uk/store

As an example I have Added the below product
(http://www.hubjub.co.uk/store/index.php/pedals/all-city-cecil-pro-detail)

i have changed the availability in the back end but it doesn't show in the product listing

Would really appreciate any help
Title: Re: Availability Field
Post by: bytelord on November 27, 2012, 13:30:57 PM
Hello,

You are using the default template as i see but do you use template overrides?

The default code for availability is there, to work is depends what you have select from the backend.
Edit your product, go to Product Status, fix the availability & products in Stock.
Also please configure your stock handle under Configuration-> Shopfront, at the top right Action when a Product is Out of Stock, select an option to handle stock ... for example Products Out of Stock are orderable, and the field 'Availability' below is displayed ...

Regards

Title: Re: Availability Field
Post by: Hujub on November 27, 2012, 13:37:35 PM
Quote from: bytelord on November 27, 2012, 13:30:57 PM
Hello,

You are using the default template as i see but do you use template overrides?

The default code for availability is there, to work is depends what you have select from the backend.
Edit your product, go to Product Status, fix the availability & products in Stock.
Also please configure your stock handle under Configuration-> Shopfront, at the top right Action when a Product is Out of Stock, select an option to handle stock ... for example Products Out of Stock are orderable, and the field 'Availability' below is displayed ...

Regards

Hi,
I havnt dont any template overrides just changed colours fonts positions...

I have Changed Product out of stock to show availability field, this does work when the product is out of stock.
Is there any way to show an availability field when the product is in stock?
Title: Re: Availability Field
Post by: bytelord on November 27, 2012, 14:00:39 PM
Hello,

You will need to create a template override for the file file for product details view that located under joomla_folder\components\com_virtuemart\views\productdetails\tmpl\default.php. To create a template override just copy that file inside your_joomla_folder\templates\your_joomla_template\html\com_virtuemart\productdetails\default.php

Edit the new overrrided file default.php and make your changes under line 208 you will find the following code:

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


Change the line 211 to

      if (($this->product->product_in_stock - $this->product->product_ordered) > 0) {

Try that, i have to test it further something going wrong there ... but this will work for you.

Regards
Title: Re: Availability Field
Post by: Hujub on November 27, 2012, 14:41:44 PM
Just UPDATED and its working!

Many many thanks

SOLVED!
Title: Re: Availability Field
Post by: bytelord on November 27, 2012, 15:35:06 PM
Ok,

i think the right code should as showed below...

So, if product availability have been selected for the product then if available stock < 1 and rised is enabled then place rised else place the availability of the product. I don't know why this have been changed ... Could be done with other way also if we correct the original one but need more code and executions... Please test the follow

<?php 
// Availability Image            
               
if (!empty($this->product->product_availability)) { 
$stockhandle VmConfig::get('stockhandle''none');
                if(
$stockhandle=='risetime' and VmConfig::get('rised_availability') 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 { ?>
                       
                    <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 
                      
}  
                        
                 } 
?>
Title: Re: Availability Field
Post by: winsonstation on March 23, 2014, 01:17:44 AM
Hello to all...

VM2.0.8 - Joomla 2.5.6

I have chosen the "Products Out of Stock are orderable, and the field 'Availability' below is displayed"

I face the same problem and i cannot fixed it, although i tried what you have said at the previous posts

First code from  /components/com_virtuemart/views/productdetails/tmpl/default.php

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



Second code from  /templates/theme310/html/com_virtuemart/productdetails/default.php

<?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
}
}
?>


If i copy/paste/overwrite the first code at the second one, then with some changes at < 1, > 1, > 0 and the number at the product status 0 or 100, then the 24h.gif it appears, but the whole product layout is being "damaged"

If i change at the second code the < 1, > 1, > 0 and the number at the product status 0 or 100, then no *.gif appears ever, and have no changes at the product layout.

Any help pls??? Thx
Title: Re: Availability Field
Post by: jenkinhill on March 23, 2014, 10:16:29 AM
Quote from: winsonstation on March 23, 2014, 01:17:44 AM
VM2.0.8 - Joomla 2.5.6

Please see http://forum.virtuemart.net/index.php?action=post;msg=402445
Title: Re: Availability Field
Post by: winsonstation on March 23, 2014, 13:36:14 PM
@jenkinhill

The link does not work. It shows me the message

An Error Has Occurred!
The board you specified doesn't exist


Title: Re: Availability Field
Post by: jenkinhill on March 23, 2014, 13:50:56 PM
Sry. Try this http://forum.virtuemart.net/index.php?topic=118683.0

That old bug if fixed for current versions.
Title: Re: Availability Field
Post by: winsonstation on March 23, 2014, 14:14:01 PM
Thank you jenkinhill.

I have thought several times to upgrade to newest versions of joomla and virtuemart, since i had also problems with products pagination but my template is compatible with these versions ( j2.5.6 and vm 2.0.8 ) and cannot run at other versions.

So untill i change the template, i have to fix some bugs.

How can i fix this problem now?

Thank you in advance