News:

Looking for documentation? Take a look on our wiki

Main Menu

hide cart button only for certain categories

Started by gio-italy, September 12, 2012, 12:01:34 PM

Previous topic - Next topic

gio-italy

joomla 2.5.6
VM 2.0.10

Hello to everyone,
I read a lot of post on "hide cart argument" but I didn' found a solution.
I'd like hide cart button only for certain categories, I tried to modify default.php on productdetails folder in my template unsuccessfully...

Does someone need that too? Who can suggest me a solution or a right street?
Thanks

All the best to everybody


ivus

Hi gio-italy,

QuoteI tried to modify default.php on productdetails folder

hmmm... it's the correct file

"/components/com_virtuemart/views/productdetails/tmpl/default.php" @ line 199. Look for:



<?php
// Add To Cart Button
//  if (!empty($this->product->prices) and !empty($this->product->images[0]) and $this->product->images[0]->file_is_downloadable==0 ) {
if (!VmConfig::get('use_as_catalog'0) and !empty($this->product->prices)) {
    echo $this->loadTemplate('addtocart');
}  // Add To Cart Button END
?>




Modify to this....



<?php
// Add To Cart Button
//  if (!empty($this->product->prices) and !empty($this->product->images[0]) and $this->product->images[0]->file_is_downloadable==0 ) {
if (!VmConfig::get('use_as_catalog'0) and !empty($this->product->prices)) {
$excludeCategories = array(1,3);
if (!in_array($this->product->virtuemart_category_id$excludeCategories )) {
echo $this->loadTemplate('addtocart');
}
}  // Add To Cart Button END
?>




Add the category IDs to this array that you want to EXCLUDE

$excludeCategories = array(1,3);

This should work.

unkelo

Hi ,

I found this old topic and i want to know can is use this eventually for my problem?

I have VM2 .0.18a and actual Joomla 2.5.8.

I have set for a product an empty price but the add to cart button isnt apperaring anymore then.
I tried to change this code from the thread to this . But is see still no add to cart button.

      <?php
      // Add To Cart Button
         if (!empty($this->product->prices) and !empty($this->product->images[0]) and $this->product->images[0]->file_is_downloadable==0 ) {
         $excludeCategories = array(23,22);
         if (!in_array($this->product->virtuemart_category_id, $excludeCategories )) {
//      if (!VmConfig::get('use_as_catalog', 0) and !empty($this->product->prices['salesPrice'])) {
          echo $this->loadTemplate('addtocart');
          }
      }  // Add To Cart Button END
      ?>
      

Can anybody help me out ?

Greetings
unkelo