Author Topic: Add To Cart From Category [Solved]  (Read 70239 times)

outthebox

  • Beginner
  • *
  • Posts: 11
Re: Add To Cart From Category [Solved]
« Reply #90 on: July 03, 2012, 00:11:16 AM »
insert after line 284:
<p>
<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
      <div class="addtocart-bar">

         <?php // Display the quantity box ?>
         <!-- <label for="quantity<?php echo $this->product->virtuemart_product_id;?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
         <span class="quantity-box">
            <input type="text" class="quantity-input" name="quantity[]" value="1" />
         </span>
         <span class="quantity-controls">
            <input type="button" class="quantity-controls quantity-plus" />
            <input type="button" class="quantity-controls quantity-minus" />
         </span>
         <?php // Display the quantity box END ?>

         <?php // Add the button
         $button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO');
         $button_cls = ''; //$button_cls = 'addtocart_button';
         if (VmConfig::get('check_stock') == '1' && !$this->product->product_in_stock) {
            $button_lbl = JText::_('COM_VIRTUEMART_CART_NOTIFY');
            $button_cls = 'notify-button';
         } ?>

         <?php // Display the add to cart button ?>
         <span class="addtocart-button">
            <input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
         </span>

      <div class="clear"></div>
      </div>

      <?php // Display the add to cart button END ?>
      <input type="hidden" class="pname" value="<?php echo $product->product_name ?>">
      <input type="hidden" name="option" value="com_virtuemart" />
      <input type="hidden" name="view" value="cart" />
      <noscript><input type="hidden" name="task" value="add" /></noscript>
      <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>" />
      <?php /** @todo Handle the manufacturer view */ ?>
      <input type="hidden" name="virtuemart_manufacturer_id" value="<?php echo $product->virtuemart_manufacturer_id ?>" />
      <input type="hidden" name="virtuemart_category_id[]" value="<?php echo $product->virtuemart_category_id ?>" />
</form>
</p>

mikkidee

  • Beginner
  • *
  • Posts: 13
Re: Add To Cart From Category
« Reply #91 on: July 03, 2012, 03:40:27 AM »
I used this code and it works beautifully... however I really need someone to help with a slight modification:

Using the code as is, the button is available to anonymous viewers - I need this disabled when unregistered viewers are browsing the store and visible to registered visitors.

I am using VM 2.0.8a on Joomla 2.5.6
Help with this would be greatly appreciated. Thanks in advance.

I need this too, basically for the store to function as a catalog for unregistered users and with store functionality for registered users.
I used the code provided and it works fine but I need to know how to hide the form (code) from unregistered visitors - not a php coder so I'm really stuck... Can anyone help with this?

Using same versions of joomla and vm as quoted.

Many thanks.

jiapei100

  • Beginner
  • *
  • Posts: 48
Re: Add To Cart From Category [Solved]
« Reply #92 on: July 03, 2012, 15:42:59 PM »

Please specify
1) which file
2) what is the original content of line 283, and what is the original content of line 285?

Thank you...


insert after line 284:
<p>
<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
      <div class="addtocart-bar">

         <?php // Display the quantity box ?>
         <!-- <label for="quantity<?php echo $this->product->virtuemart_product_id;?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
         <span class="quantity-box">
            <input type="text" class="quantity-input" name="quantity[]" value="1" />
         </span>
         <span class="quantity-controls">
            <input type="button" class="quantity-controls quantity-plus" />
            <input type="button" class="quantity-controls quantity-minus" />
         </span>
         <?php // Display the quantity box END ?>

         <?php // Add the button
         $button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO');
         $button_cls = ''; //$button_cls = 'addtocart_button';
         if (VmConfig::get('check_stock') == '1' && !$this->product->product_in_stock) {
            $button_lbl = JText::_('COM_VIRTUEMART_CART_NOTIFY');
            $button_cls = 'notify-button';
         } ?>

         <?php // Display the add to cart button ?>
         <span class="addtocart-button">
            <input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
         </span>

      <div class="clear"></div>
      </div>

      <?php // Display the add to cart button END ?>
      <input type="hidden" class="pname" value="<?php echo $product->product_name ?>">
      <input type="hidden" name="option" value="com_virtuemart" />
      <input type="hidden" name="view" value="cart" />
      <noscript><input type="hidden" name="task" value="add" /></noscript>
      <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>" />
      <?php /** @todo Handle the manufacturer view */ ?>
      <input type="hidden" name="virtuemart_manufacturer_id" value="<?php echo $product->virtuemart_manufacturer_id ?>" />
      <input type="hidden" name="virtuemart_category_id[]" value="<?php echo $product->virtuemart_category_id ?>" />
</form>
</p>

jiapei100

  • Beginner
  • *
  • Posts: 48
Re: Add To Cart From Category [Solved]
« Reply #93 on: July 03, 2012, 15:54:34 PM »
Hi, outthebox:

It's better for you to afford a download for the file you talked about. If we can download and have a look at the file you talked about, we may do a comparison and make things much easier. Thank you very much...

Best Rgds
Pei

insert after line 284:
<p>
<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
      <div class="addtocart-bar">

         <?php // Display the quantity box ?>
         <!-- <label for="quantity<?php echo $this->product->virtuemart_product_id;?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
         <span class="quantity-box">
            <input type="text" class="quantity-input" name="quantity[]" value="1" />
         </span>
         <span class="quantity-controls">
            <input type="button" class="quantity-controls quantity-plus" />
            <input type="button" class="quantity-controls quantity-minus" />
         </span>
         <?php // Display the quantity box END ?>

         <?php // Add the button
         $button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO');
         $button_cls = ''; //$button_cls = 'addtocart_button';
         if (VmConfig::get('check_stock') == '1' && !$this->product->product_in_stock) {
            $button_lbl = JText::_('COM_VIRTUEMART_CART_NOTIFY');
            $button_cls = 'notify-button';
         } ?>

         <?php // Display the add to cart button ?>
         <span class="addtocart-button">
            <input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
         </span>

      <div class="clear"></div>
      </div>

      <?php // Display the add to cart button END ?>
      <input type="hidden" class="pname" value="<?php echo $product->product_name ?>">
      <input type="hidden" name="option" value="com_virtuemart" />
      <input type="hidden" name="view" value="cart" />
      <noscript><input type="hidden" name="task" value="add" /></noscript>
      <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>" />
      <?php /** @todo Handle the manufacturer view */ ?>
      <input type="hidden" name="virtuemart_manufacturer_id" value="<?php echo $product->virtuemart_manufacturer_id ?>" />
      <input type="hidden" name="virtuemart_category_id[]" value="<?php echo $product->virtuemart_category_id ?>" />
</form>
</p>

outthebox

  • Beginner
  • *
  • Posts: 11
Re: Add To Cart From Category
« Reply #94 on: July 04, 2012, 00:34:44 AM »
Hi Pei

The file I edited is: [yoursite]/components/com_virtuemart/views/category/tmpl/default.php
 - From what I have read in these forums, it seems there is a way to use a template for this instead of editing this default file but I haven't got to that yet - I'm far more familiar with VM 1 and still getting used to VM 2.

As for what was originally on line 284, it's and end div tag for the price display. The code (form) goes between that and the next line of code which is for the product details button. I have attached my default.php file so you can see what I mean.
 - You should be able to simply replace the one that's there with this one.

Hope this helps.

Mike

jiapei100

  • Beginner
  • *
  • Posts: 48
Re: Add To Cart From Category
« Reply #95 on: July 04, 2012, 14:50:03 PM »
Hi, Thank you so much outthebox...
Problem solved...
Thanks !!!!!

Best Regards
Pei

Hi Pei

The file I edited is: [yoursite]/components/com_virtuemart/views/category/tmpl/default.php
 - From what I have read in these forums, it seems there is a way to use a template for this instead of editing this default file but I haven't got to that yet - I'm far more familiar with VM 1 and still getting used to VM 2.

As for what was originally on line 284, it's and end div tag for the price display. The code (form) goes between that and the next line of code which is for the product details button. I have attached my default.php file so you can see what I mean.
 - You should be able to simply replace the one that's there with this one.

Hope this helps.

Mike

edcv

  • Beginner
  • *
  • Posts: 29
Re: Add To Cart From Category [Solved]
« Reply #96 on: July 12, 2012, 02:45:32 AM »
I just wanted to add my solution to this problem as I did not modify any of the root virtuemart code and it includes the custom fields.

It seems to work fine, should not be overwritten if you update virtumart and it is easy to revert to the original virtuemart later.

These are the steps
1 Create a folder rootOfYourSite/templates/yourTemplate/html/com_virtuemart/category
Files included in this folder will have higher preference ("overwrite")  than the orginal virtuemart files

2 Copy default.php to the folder created in step 1
This is the original virtuemart file from components/com_virtuemart/views/category/tmlp/default.php
ecxept for lines 288 where I include addToCartCategory.php and line 291 which is commented out.
In line 252 I included the full description instead of short description of the product

3 Copy addToCartCategory.php to the folder created in step 1
This is the original virtuemart file from components/com/virtuemart/views/productdetails/tmpl/default_addtocart.php
except I did replace all $this->product with $product

Hope this is useful for someone

Would also like to thank the virtuemart team for making these modifications so elegant :)

Edit: Fixed typo in path and some clarification

jiapei100

  • Beginner
  • *
  • Posts: 48
Re: Add To Cart From Category [Solved]
« Reply #97 on: July 12, 2012, 16:12:00 PM »
....

3 Copy addToCartCategory.php to this folder
This is the original virtuemart file from components/com/virtuemart/views/productdetails/view/default_addtocart.php
except I did replace all $this->product with $product

....

It seems the above address is wrong. Should be
components/com_virtuemart/views/productdetails/tmpl/default_addtocart.php
instead of
components/com_virtuemart/views/productdetails/view/default_addtocart.php



Best Regards
Pei

jiapei100

  • Beginner
  • *
  • Posts: 48
Re: Add To Cart From Category [Solved]
« Reply #98 on: July 12, 2012, 16:28:08 PM »


Are you sure, just by "uploading such a folder with 2 files in this folder" would work?
It seems, nothing happened on my product categories.


Cheers
Pei


I just wanted to add my solution to this problem as I did not modify any of the root virtuemart code and it includes the custom fields.

It seems to work fine, should not be overwritten if you update virtumart and it is easy to revert to the original virtuemart later.

These are the steps
1 Create a folder rootOfYourSite/templates/yourTemplate/html/com_virtuemart/category
Files included in this folder will have higher preference ("overwrite")  than the orginal virtuemart files

2 Copy default.php to this folder
This is the original virtuemart file from components/com_virtuemart/views/category/html/tmlp/default.php
ecxept for lines 288 where I include addToCartCategory.php and line 291 which is commented out.
In line 252 I included the full description instead of short description of the product

3 Copy addToCartCategory.php to this folder
This is the original virtuemart file from components/com/virtuemart/views/productdetails/view/default_addtocart.php
except I did replace all $this->product with $product

Hope this is useful for someone

Would also like to thank the virtuemart team for making these modifications so elegant :)

edcv

  • Beginner
  • *
  • Posts: 29
Re: Add To Cart From Category [Solved]
« Reply #99 on: July 13, 2012, 02:04:13 AM »


Are you sure, just by "uploading such a folder with 2 files in this folder" would work?
It seems, nothing happened on my product categories.


Cheers
Pei

Sorry you were right about the path, I had to write all the text twice as the first time the forum
system didn't accept my attachments so I was a little bit sloppy maybe the second time.

I was maybe not very clear about it in my post (modified it now) but everything should be put into
the folder that you created in step 1.

This works fine for me, have not found anything drawbacks. I'm using custom fields on some of my products
and it works like a charm.

Javix

  • Beginner
  • *
  • Posts: 10
Re: Add To Cart From Category [Solved]
« Reply #100 on: July 15, 2012, 06:14:23 AM »
Just wanted to say thanks for this great hack!

Regards

karun2520

  • Beginner
  • *
  • Posts: 1
Re: Add To Cart From Category [Solved]
« Reply #101 on: July 17, 2012, 03:52:11 AM »
Please get the code for Virtuemart 2.0.6 and Joomla  2.5.6

_kuro

  • Beginner
  • *
  • Posts: 15
Re: Add To Cart From Category [Solved]
« Reply #102 on: July 17, 2012, 09:07:14 AM »
My question is:

How can i redirect the button "add to cart" to the same page?

Guessing i'm at page 12 of X category . . when i add a product at cart (and pop up print the sentence "Continue shopping" and we do click on the button), this send me to the first page of category ¬¬

If someone has the answer.. please, help me!!

Thanks and have a nice day


communion

  • Beginner
  • *
  • Posts: 19
Re: Add To Cart From Category - not in IE 9?
« Reply #103 on: July 18, 2012, 18:58:28 PM »
I can't seem to get this to work in IE 9 only, can someone take a look? It works in browser compat mode (though the popup needs to be restyled in CSS)

http://www.leeoskarpaintings.com/test/spring-and-summer.html

Thanks,

-Communion

booll3t

  • Beginner
  • *
  • Posts: 1
Re: Add To Cart From Category [Solved]
« Reply #104 on: July 30, 2012, 01:17:57 AM »
I can't seem to find this file on the specified path /components/com_virtuemart/views/category/tmpl/default.php..... When i open the file there's nothing such as the quoted text.... Please help me find the one where i can edit addToCart text because it is written "TM_VIRTUEMART_CART_ADD_TO" to simply "add to cart"...

Please help



insert after line 284:
<p>
<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
      <div class="addtocart-bar">

         <?php // Display the quantity box ?>
         <!-- <label for="quantity<?php echo $this->product->virtuemart_product_id;?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
         <span class="quantity-box">
            <input type="text" class="quantity-input" name="quantity[]" value="1" />
         </span>
         <span class="quantity-controls">
            <input type="button" class="quantity-controls quantity-plus" />
            <input type="button" class="quantity-controls quantity-minus" />
         </span>
         <?php // Display the quantity box END ?>

         <?php // Add the button
         $button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO');
         $button_cls = ''; //$button_cls = 'addtocart_button';
         if (VmConfig::get('check_stock') == '1' && !$this->product->product_in_stock) {
            $button_lbl = JText::_('COM_VIRTUEMART_CART_NOTIFY');
            $button_cls = 'notify-button';
         } ?>

         <?php // Display the add to cart button ?>
         <span class="addtocart-button">
            <input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
         </span>

      <div class="clear"></div>
      </div>

      <?php // Display the add to cart button END ?>
      <input type="hidden" class="pname" value="<?php echo $product->product_name ?>">
      <input type="hidden" name="option" value="com_virtuemart" />
      <input type="hidden" name="view" value="cart" />
      <noscript><input type="hidden" name="task" value="add" /></noscript>
      <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>" />
      <?php /** @todo Handle the manufacturer view */ ?>
      <input type="hidden" name="virtuemart_manufacturer_id" value="<?php echo $product->virtuemart_manufacturer_id ?>" />
      <input type="hidden" name="virtuemart_category_id[]" value="<?php echo $product->virtuemart_category_id ?>" />
</form>
</p>

VirtueMart Forum

Re: Add To Cart From Category [Solved]
« Reply #104 on: July 30, 2012, 01:17:57 AM »