VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: gyvr on February 11, 2013, 14:23:34 PM

Title: Add to cart in category
Post by: gyvr on February 11, 2013, 14:23:34 PM
hello.
We wanted customer be able to buy from the category description, not having to go to the detailed description. This make sense to us since customer are re-ordering same products times and times and do not need to read details description.

Even though it seems working for us, we do not know if there can be side effect that would create more problems than what we actually try to solve. We would appreciate any comment, and may be have it included as "standard" approach in a furture release?

So we override the VM category default.php.
Around line 204:
   // Count products ?? why not just count ($this->products)  ?? note by Max Milbers
   $BrowseTotalProducts = 0;
   foreach ($this->products as $product) {
      $BrowseTotalProducts++;
   }
   foreach ($this->products as $product) {
   
Add the following line right here:
      $this->product =  $product;

Remove (or comment all code in between) line 288
               <div class="product-price marginbottom12" id="productPrice<?php echo $product->virtuemart_product_id ?>">
                  <?php

Down to line 313:

$unitPriceDescription, $product->prices);
                     }
                     ?>

This will remove displaying the the price (The price is not displayed in the same way on this page an on the prodeuct detailed page depending on which prices you choose to dispaly)

Then add the following

<?php
      // Product Price
      echo $this->loadTemplate('showprices');
      // (price now shows up exact same as in detailed view

      // Add To Cart Button
      echo $this->loadTemplate('addtocart');
      // Add To Cart Button END
?>

Even though un-modifieid, we also had to copy "default_addtocart" "default_showprices" and "default_customfields" into our overriding directory to get the modification working (since they were associated to the product detailed view and not defined as globally accessible resources).

We appreciate any comments for a better approach.

regards
Gerard
Title: Re: Add to cart in category
Post by: jenkinhill on February 12, 2013, 12:38:47 PM
Long thread about that here:  http://forum.virtuemart.net/index.php?topic=90961.0
Title: Re: Add to cart in category
Post by: gyvr on February 17, 2013, 11:10:31 AM
Ki Kelvin
Thanks for the pointer. In fact I had seen it but failed to browse up to the end and stayed on topics related to "old" VM Version. i need to dig into the details of the most recent posts, but the thread looks promising.

Gerard