Add to cart on category intro page

Rate this topic: Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.1.00 out of 6 based on 1 vote(s)
GK User
Sun May 19, 2013 3:00 am
Reply with quote
Report this post
Hi again,

Is there a way to activate the ADD TO CART button on products on the category page? Right now, have no option to click on the product detail to be able to add a specific product to cart.

Any help would be appreciated !!

Thank you
User avatar
Fresh Boarder

GK User
Sun May 19, 2013 8:46 am
Reply with quote
Report this post
Image

Open File:/templates/gk_storebox/html/com_virtuemart/category/default.php
Line: 262 which line starts with below code.
Code: Select all
<a href="<?php echo $product->link; ?>"

Copy and paste below code after above line.
Code: Select all
<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';
         } ?>
         <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>
      <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 ?>" />
      <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>

Below is optional if you want to show + - in quantity boxes.

Open file: css/override.css and add below css code. Enable css override in template settings > advanced settings > css override. If you are using different template style edit the colors in last 2 hover lines to match your style color.
Code: Select all
.quantity-plus {background: url(../images/vm/cartquantity.png) no-repeat 0 0 #000000!important;}
.quantity-minus {background: url(../images/vm/cartquantity.png)no-repeat 0 -38px #000000!important;}
.quantity-plus:hover {background: url(../images/vm/cartquantity.png) no-repeat 0 0 #ff7e57!important;}
.quantity-minus:hover {background: url(../images/vm/cartquantity.png)no-repeat 0 -38px #ff7e57!important;}


Download attached zip file which contains image file for + - quantity box. Upload image to "/templates/gk_storebox/images/vm/cartquantity.png".

Attached file also includes edited "/templates/gk_storebox/html/com_virtuemart/category/default.php" if you haven't done any modifications simply overwrite your own file.

See you around...
User avatar
Platinum Boarder

GK User
Mon May 20, 2013 4:16 pm
Reply with quote
Report this post
Thanks so much Norman, it works perfectly, exactly what I wanted, your the best !! Cheers
User avatar
Fresh Boarder

GK User
Thu May 23, 2013 10:15 am
Reply with quote
Report this post
No problem at all, see you around :)
User avatar
Platinum Boarder

GK User
Fri Jun 07, 2013 7:43 pm
Reply with quote
Report this post
Hello,

I have an issue with this, if I remove in this file code to delete quantity +- buttons and only show quantity field and add to cart button I get a js conflict with IE9.
Work fine with FF, Chrome, Safari and IE8 but with IE9 when click in add to cart product don't add to cart and go to index page, checkout page or give a js error.

Could you help me with this?

I think that a solution may be hide with css (only with css) +- quantity button because I don't want have this +- buttons... How can I make this? Is this a good solution for this issue that I think that is related to atributtes product/VM?

Thanks.
User avatar
Fresh Boarder

GK User
Mon Jun 10, 2013 10:58 am
Reply with quote
Report this post
You can hide it with css
Code: Select all
.quantity-controls { display:none;}


Or you can use below code if you don't want quantity buttons in code.

Code: Select all
<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
      <div class="addtocart-bar">
         <?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';
         } ?>
         <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>
      <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 ?>" />
      <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>


See you around...
User avatar
Platinum Boarder

GK User
Sat Jul 20, 2013 4:30 am
Reply with quote
Report this post
An important post and great solution from Norman,

Thanks for providing us with quantity controls icons. Wh they are missed from the template?
User avatar
Fresh Boarder

GK User
Thu Aug 08, 2013 5:34 am
Reply with quote
Report this post
Well it is all about design, maybe Gavick thought it would look better without it : )

See you around...
User avatar
Platinum Boarder

GK User
Tue Oct 15, 2013 2:32 am
Reply with quote
Report this post
Hello,
in the category, when we added the button, is it possible for products that have no stock to change the button image for "not available"?
Thank you very much in advance.
: D
User avatar
Fresh Boarder

GK User
Tue Oct 15, 2013 2:33 am
Reply with quote
Report this post
Hello,
in the category, when we added the button, is it possible for products that have no stock to change the button image for "not available"?
Thank you very much in advance.
: D
User avatar
Fresh Boarder

GK User
Tue Oct 15, 2013 2:39 am
Reply with quote
Report this post
thanks for the replies, sorry for repeating the question in this forum, I realized that I'd already answered. thank you: D .. I perform these tests and if I give the solution I communicate.
User avatar
Fresh Boarder

GK User
Fri Sep 26, 2014 6:32 pm
Reply with quote
Report this post
Hi,
I've applied your instructions (on default.php and override.css) on my website (joomla 2.5.24 and VM 2.6.10), and it seems to be working, but for one detail: I can't download the png you made available and I get this message:
The selected attachment does not exist anymore.
Even avoiding override.css addition, I get this result
addtocartquantitybuttons.png

Would you please re-upload the file?

Graphic details apart, I've set up my products with value 6 on Product Status/Purchase Quantity Steps, which means visitors can buy the product only with multiple of 6 quantities (6,12,18...), and if they click on + product quantity is increased by 6. Without Storebox template, the system works on category and product details, otherwise product increases are 1 by 1. Is there a way to re-establish the correct behaviour?

Regarding this, I would also like to display quantity +/- buttons on product detail page, in order to make work the 6+ quantity steps system, would you please show me how to do it? Now it is like this:
addtocartbuttonsdetails.png


Best regards,
Guido
User avatar
Senior Boarder

GK User
Fri Sep 26, 2014 6:41 pm
Reply with quote
Report this post
Forgive me, I forgot to uncomment the code to display +/- on add to cart, now they show up, but still
- the 6+ steps don't work
- your png files aren't available
thanks for your help
User avatar
Senior Boarder

GK User
Thu Oct 02, 2014 3:50 pm
Reply with quote
Report this post
Sorry for the delay, quantity image is attached to this post.
User avatar
Platinum Boarder

GK User
Thu Oct 02, 2014 4:30 pm
Reply with quote
Report this post
Don't worry, do you have any comments on this part?

Graphic details apart, I've set up my products with value 6 on Product Status/Purchase Quantity Steps, which means visitors can buy the product only with multiple of 6 quantities (6,12,18...), and if they click on + product quantity is increased by 6. Without Storebox template, the system works on category and product details, with gavick quickstart just installed product increases are only 1 by 1. Is there a way to re-establish the correct behaviour?
User avatar
Senior Boarder

GK User
Fri Oct 03, 2014 12:23 am
Reply with quote
Report this post
Is this in category view or product view or both?
User avatar
Platinum Boarder

GK User
Fri Oct 03, 2014 8:38 am
Reply with quote
Report this post
Both views allow quantity increases by 1 and not more.
I've tried changing category template and going back to the default but the functionality didn't come back.
User avatar
Senior Boarder

GK User
Sat Oct 04, 2014 2:14 am
Reply with quote
Report this post
Are you using any plugins for this ?
User avatar
Platinum Boarder

GK User
Mon Oct 06, 2014 8:24 am
Reply with quote
Report this post
Not at all, it's the gavick quickstart with virtuemart 2.6.10. I've only added akeeba backup and acl manager
User avatar
Senior Boarder

GK User
Mon Oct 06, 2014 10:37 am
Reply with quote
Report this post
Please open following file:
Code: Select all
\templates\gk_storebox\html\com_virtuemart\productdetails\default.php

Find Line: 24 which is below
Code: Select all
/* Let's see if we found the product */
if (empty($this->product)) {
   echo JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
   echo '<br /><br />  ' . $this->continue_link_html;
   return;
}

Replace with below code
Code: Select all
/* Let's see if we found the product */
if (empty($this->product)) {
   echo JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
   echo '<br /><br />  ' . $this->continue_link_html;
   return;
}

/* Fix for multiple quantity in products quantity steps */
if (isset($this->product->step_order_level))
   $step=$this->product->step_order_level;
else
   $step=1;
if($step==0)
   $step=1;
$alert=JText::sprintf ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED', $step);

Find Line: 320 / 321 or below code depending on your edit
Code: Select all
                     <div class="addtocart-area">
                           <form method="post" class="product js-recalculate" action="<?php echo JRoute::_('index.php',false); ?>" >

replace it with below
Code: Select all
                     <div class="addtocart-area">
                           <form method="post" class="product js-recalculate" action="<?php echo JRoute::_('index.php',false); ?>" >
                                 <input name="quantity" type="hidden" value="<?php echo $step ?>" />

Now + / - buttons should show whatever steps you defined in product status tab in admin panel.

Let me know if you need further help. See you around...
User avatar
Platinum Boarder

GK User
Mon Oct 06, 2014 11:25 am
Reply with quote
Report this post
Hi, I've got no \templates\gk_storebox\html\com_virtuemart\productdetails\default_addtocart.php
In that directory there's only default.php and index.html
I've also just downloaded last version of quickstart and template, and it's the same.
I hope you're talking about J2.5 version...
If you send me the file, I can add it.
User avatar
Senior Boarder

GK User
Mon Oct 06, 2014 11:43 am
Reply with quote
Report this post
My mistake, file is default.php.
User avatar
Platinum Boarder

GK User
Mon Oct 06, 2014 12:05 pm
Reply with quote
Report this post
Norman, thank you for your help, but it doesn't seem to work.
I've applied, checked and re-checked modifications you listed here, but like this does not even increase quantities (only the first product)...
http://www.imbottigliamo.it/liquorit/in ... n/cream-it
I got back to the atomic template and with that the +6 works well.
Please, have a look at this.
User avatar
Senior Boarder

GK User
Mon Oct 06, 2014 8:26 pm
Reply with quote
Report this post
I have tested this already, send me an ftp access to my email normanuk[at]live.co.uk and I ll take a look at your setup, or attact your default.php file in a zip file in here so I can test it in my server. See you around...
User avatar
Platinum Boarder

GK User
Tue Oct 07, 2014 11:09 am
Reply with quote
Report this post
Thanks Norman, I've sent you an email. If you agree I'll post the solution here.
User avatar
Senior Boarder

GK User
Tue Oct 07, 2014 9:51 pm
Reply with quote
Report this post
I have just tested your file in my server, uncommented + / - code in default.php and it works fine. Perhaps it is your vm settings causing this. Send me your admin details for your website and I ll take a look there.

See you around...
User avatar
Platinum Boarder

GK User
Tue Oct 14, 2014 1:47 pm
Reply with quote
Report this post
Norman, I've sent you details per mail about my admin access, did you receive them?
Please let me know
User avatar
Senior Boarder

GK User
Wed Oct 15, 2014 7:44 am
Reply with quote
Report this post
I did sent you a reply. Your servers admin panel had problems when I ve checked it, it was keep timing out. I ll check it now...
User avatar
Platinum Boarder

GK User
Wed Oct 15, 2014 7:48 am
Reply with quote
Report this post
I have just seen your other emails, I ll check everything now...

Edit: I still cannot access admin panel. "The connection was reset" error when logging in.
User avatar
Platinum Boarder

GK User
Wed Oct 15, 2014 8:29 am
Reply with quote
Report this post
I've just checked and it works for me with info I've sent you.
Please retry now and let me know.
Thanks in advance
User avatar
Senior Boarder

GK User
Wed Oct 15, 2014 10:07 pm
Reply with quote
Report this post
Still same error, connection was reset. This happens either while logging in, or entering virtuemart products, or editing product status. Please check your php memory limit for this server.

So do following please, set virtuemart template to "default", setup one of your products for multiple quantity. This is in virtuemart > products > products status;
Code: Select all
Purchase Quantity Steps:
Minimum Purchase Quantity:
In Stock:

Make sure item stock level is increased. Let me know which product you have added then I will check the files from your ftp.

Alternatively zip your website files and database and send me a link which I can test your installation in my local server.
User avatar
Platinum Boarder

GK User
Tue Nov 18, 2014 4:07 pm
Reply with quote
Report this post
Hi, how I can add button add to cart to hover effect ? That means when I get the mouse on a product that does not appear as well as the opportunity to show Add to Cart. thank you
User avatar
Fresh Boarder


cron