VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: lalila on April 19, 2016, 13:03:48 PM

Title: Remove add-to-cart from category page only when there is no prices
Post by: lalila on April 19, 2016, 13:03:48 PM
Hello

I'm trying to remove the price of categories pages that have no price but keep it for categories with prices.
Does anyone have an idea how to get this working ?

Thank you

It should be this file, i duplicate it and affect to categories with no prices:
/html/com_virtuemart/category/default.php

Trying to remove this clas :
<div class="vm3pr-4"> <div>
<div class="vm3pr-0"> <div>

Joomla 3.4.8
Virtuemart 3.0.12
PHP 5.4.45
Title: Re: Remove add-to-cart from category page only when there is no prices
Post by: jenkinhill on April 19, 2016, 13:26:03 PM
div class="vm3pr-  is in components/com_virtuemart/sublayouts/products.php
Title: Re: Remove add-to-cart from category page only when there is no prices
Post by: lalila on April 20, 2016, 11:27:27 AM
Thanks, but if i remove the following code in components/com_virtuemart/sublayouts/products.php the price is removed for ALL categories pages.


<?php //echo $rowsHeight[$row]['price'] ?>
<div class="vm3pr-<?php echo $rowsHeight[$row]['price'?>"> <?php
echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$product,'currency'=>$currency)); ?>

<div class="clear"></div>
</div>
<?php //echo $rowsHeight[$row]['customs'] ?>
<div class="vm3pr-<?php echo $rowsHeight[$row]['customfields'?>"> <?php
echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product,'rowHeights'=>$rowsHeight[$row], 'position' => array('ontop''addtocart'))); ?>

</div>


I'd like to create differents category page. Somes categories are for products with prices, others are on quotation :
1/ www/templates/mytemplate/html/com_virtuemart/category/default.php
2/ www/templates/mytemplate/html/com_virtuemart/category/quotation.php

Is it possible ?
Title: Re: Remove add-to-cart from category page only when there is no prices
Post by: Jörgen on April 20, 2016, 13:55:05 PM
Hello

Yes of course. Make a copy of the file You want to start with. and name it like you have done. Then You can choose this template under the setup for the product category You want to assign the new quotation.php to.

regards

Jörgen @ Kreativ Fotografi


Title: Re: Remove add-to-cart from category page only when there is no prices
Post by: Ghost on April 20, 2016, 14:24:53 PM
See sublayouts http://docs.virtuemart.net/tutorials/templating-layouts/199-sublayouts.html
Title: Re: Remove add-to-cart from category page only when there is no prices
Post by: Jörgen on April 20, 2016, 14:33:39 PM
Hello

@ghost
Good suggetsion, but this is not a work for sublayouts only. This could very well be combined with sublayouts. But You can not assign sublayouts to product category directly.

@lalila You may also have to create a new sublayout and use this in Your new template view, quotation.php. Then You can assign the quotation.php to the categories You like.

regards

Jörgen @ Kreativ Fotografi
Title: Re: Remove add-to-cart from category page only when there is no prices
Post by: Ghost on April 20, 2016, 14:47:05 PM
You can but only in category menu item. Sounds like a missing feature.

Depending on what exactly are you trying to accomplish, a simpler option could be to check if product has a price and add the addtocart sublayout if it does:

<?php if($product->prices['salesPrice']){?>
<div class="vm3pr-<?php echo $rowsHeight[$row]['customfields'?>"> <?php
echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product,'rowHeights'=>$rowsHeight[$row], 'position' => array('ontop''addtocart'))); ?>

</div>
<?php }?>


Just to be sure. If you want "ask for price" to be shown on products without price, just check "Show call for price, when the price is empty" option in VM Config.
Title: Re: Remove add-to-cart from category page only when there is no prices
Post by: Jörgen on April 20, 2016, 15:30:05 PM
Hello again

I read Your question badly.
QuoteQuote from Ghost
just check "Show call for price, when the price is empty" option in VM Config.

Just look into sublayout prices, there You can see how the note Call for price is displayed instead when prices are missing. Either modify or copy prices.php and modify as new sublayout.

regards

Jörgen @ Kreativ Fotografi