News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Add to cart in category

Started by gyvr, February 11, 2013, 14:23:34 PM

Previous topic - Next topic

gyvr

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

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

gyvr

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