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

TOPIC: Instock/availab. to be disabled for parent product

Instock/availab. to be disabled for parent product 11 years 3 months ago #1862

On the page of a product with child options, the “Add to cart” button is disabled. So you are not able to order the parent product.

So far, so good....

At the same page, we would like for the “In stock” text to be disabled. And appear when a child product has been chosen.

And the same with the "Availability image" we have underneath the "In stock" text. It should appear only after having chosen the child product.

:)
The topic has been locked.

Instock/availab. to be disabled for parent product 11 years 3 months ago #1866

Hi,

This is doable but this might give you some problem if you have multiple custom fields type in your website.
For instance; if you are using "generic child variant" ONLY in your website, you will be good to go, but if you have "generic child product" but also have some other "custom fields" types as well. Then this would give a confusion to because the PHP patch that i am going to give you below will hide the "stock info" from all parent products. (if any product doesn't have custom field at all, they won't be affected from this change)

Open this PHP file:

templates/....../html/com_virtuemart/productdetails/default_addtocart.php

and find this PHP lines:
<div class="FlexibleInStock"><?php echo JText::_('COM_VIRTUEMART_PRODUCT_IN_STOCK'); ?></div>
         <?php if (VmConfig::get ( 'display_stock', 1 )) { ?><div class="FlexibleInStockLevel"><?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP'); ?>: (<?php echo $this->product->product_in_stock; ?>)</div> <?php } ?>

(they are around 102nd and 103rd lines by default)

And change them with these:
<?php if (empty($this->product->customfieldsCart)) { ?>
         <div class="FlexibleInStock"><?php echo JText::_('COM_VIRTUEMART_PRODUCT_IN_STOCK'); ?></div>
         <?php if (VmConfig::get ( 'display_stock', 1 )) { ?><div class="FlexibleInStockLevel"><?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP'); ?>: (<?php echo $this->product->product_in_stock; ?>)</div> <?php } ?>
         <?php } ?>

In case you don't see it, I added extra IF...END condition to show the stock information. So, if that particular parent product includes some "Cart" custom field, then the stock text won't appear. This is what you are looking for, the parent product won't show any stock text, but it will be shown when the child product is chosen.

Regards.
The topic has been locked.

Instock/availab. to be disabled for parent product 11 years 3 months ago #1871

Thanks! :)

This is what I have in my file after you helped me a couple of days ago:
 
<?php if (VmConfig::get ( 'display_stock', 1 )) { ?>
 
<?php $StockNumber = $this->product->product_in_stock;
	if ($StockNumber < 1) { // this indicates the product stock number is less than zero
?>
	<div class="FlexibleInStockLevel"><span style="color:#F00;"><?php echo $StockNumber; ?> <?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP'); ?></span></div>
<?php } else { // this indicates if the product stock number is equal to One or greater than One, which means it is in stock 
?>
	<div class="FlexibleInStockLevel"><span style="color:#090;"><?php echo $StockNumber; ?> <?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP'); ?></span></div>	
<?php } ?>
 
<?php } ?>

I tried to put the if...end, but there was no change... Where does the if...end go excactly?
<?php if (empty($this->product->customfieldsCart)) { ?>
			<?php } ?>

:)
Last Edit: 11 years 3 months ago by Support.
The topic has been locked.

Instock/availab. to be disabled for parent product 11 years 3 months ago #1884

Hi,

You should use this:
<?php if (empty($this->product->customfieldsCart)) { ?>
 
<?php if (VmConfig::get ( 'display_stock', 1 )) { ?>
 
<?php $StockNumber = $this->product->product_in_stock;
	if ($StockNumber < 1) { // this indicates the product stock number is less than zero
?>
	<div class="FlexibleInStockLevel"><span style="color:#F00;"><?php echo $StockNumber; ?> <?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP'); ?></span></div>
<?php } else { // this indicates if the product stock number is equal to One or greater than One, which means it is in stock 
?>
	<div class="FlexibleInStockLevel"><span style="color:#090;"><?php echo $StockNumber; ?> <?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP'); ?></span></div>	
<?php } ?>
 
<?php } ?>
 
<?php } ?>

Did you try this already?This should be the solution you are looking for. I have tested it already in my local machine to make sure it hides the "in stock" text from the parent products when the "generic child variant" custom field has been used.

Regards.
Last Edit: 11 years 3 months ago by Support.
The topic has been locked.

Instock/availab. to be disabled for parent product 11 years 3 months ago #1894

I tried your way, but no change.

Just so that we speak of the same:

When opening a product detail page with child variants, we don't want the availability image to show. Nor the out of stock text.

But as soon as a choice for child variant has been chosen, we would like the availability image and out of stock/in stock text to appear.

The reason is: If the parent product show out of stock and i.e. 30 days delivery, we are afraid people would think that applies for all child products.. And then they don't even bother to choose a child variant to see if that product is in stock or not....

:)
The topic has been locked.

Instock/availab. to be disabled for parent product 11 years 3 months ago #1897

I understand what you are trying to do. And this IF...END condition should fit your needs though, i don't know why you couldn't make it work.

I guess i have your FTP credentials, as i remember you and you have sent them to This email address is being protected from spambots. You need JavaScript enabled to view it. recently. If they are still valid, i am now taken care of it in your website.

Give me couple minutes.

Regards.
The topic has been locked.

Instock/availab. to be disabled for parent product 11 years 3 months ago #1898

Thank you... I'll be waiting.. :)
The topic has been locked.

Instock/availab. to be disabled for parent product 11 years 3 months ago #1899

Hi,

Okay, i have completed my work in your website.
I only edited this PHP file:
wwx.kollevold.no/templates/allrounder-j1.6/html/com_virtuemart/productdetails/default_addtocart.php

I disabled the "stock text", "availability image" and also disable the "quantity buttons" as those buttons are unnecessary.

So the final look become like these:

Parent products:

Attachment ScreenShot2013-01-03at1.38.46AM.png not found



If the child product is selected:

Attachment ScreenShot2013-01-03at1.39.11AM.png not found



I believe this is what you were looking for, So the proper PHP IF...END rule in your case was this:
<?php if (!preg_match("/produktvariant/i", "".shopFunctionsF::getAddToCartButton($this->product->orderable)."")) { ?>

But i have already taken care of this in your website. I am providing what i have done here, in case anyone might need the same solution as well.

Regards.
Forum Support.
The topic has been locked.

Instock/availab. to be disabled for parent product 11 years 3 months ago #1900

Thank you, thank you, thank you!

You're the best!!!!

:-D
The topic has been locked.

Instock/availab. to be disabled for parent product 11 years 3 months ago #1901

your welcome.
I am glad things get worked out as expected. Enjoy our VM Template ;)

Case solved. Topic is closed.

Regards.
Forum Support.
The topic has been locked.
Time to create page: 0.275 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