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

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10293
  • VirtueMart Version: 3+
Re: Add the "add to cart" button to the category view [Solved]
« Reply #30 on: November 02, 2011, 18:11:21 pm »
charles, thats because you will have a java conflict with your template.

Does your template, modules or anything else already use jquery? if so, turn off virtuemart jquery.

Have you tried another joomla template to see if its conflicting?

I tried that code, and it worked. Just when i posted it 30 minutes ago
I do NOT do development work for hire.

charles99

  • Jr. Member
  • **
  • Posts: 61
Re: Add the "add to cart" button to the category view [Solved]
« Reply #31 on: November 02, 2011, 23:37:13 pm »
I have tried 3 different templates!  One from Joomlart, Joomlaxtc and Yootheme. And I am getting the same clicking error or click once and two items are added to the cart.  And I am not running into any JS conflicts.   And I am getting this error in J1.5.24 and J1.7.2.   

Has anyone else solved this problem with the add to cart button? 

CranialBlaze

  • Jr. Member
  • **
  • Posts: 120
Re: Add the "add to cart" button to the category view [Solved]
« Reply #32 on: November 03, 2011, 06:03:22 am »
I had a JS conflict with the cart button when using yoothemes widget kit, i disabled the widgetkit system pluggin and all the problems went away, to date i still dont know what that pluggin does as all 3 of the WK elements i use are still working perfectly.

Have a look through your pluggins, if you have tries 3 tempaltes then whats left is custom addons, either a module thats on that page or a pluggin which normally loads globally.
I don't believe, therefore it does not exist

Joomla 2.5 VM 2.0.2

carbon

  • Beginner
  • *
  • Posts: 22
Re: Add the "add to cart" button to the category view [Solved]
« Reply #33 on: November 08, 2011, 05:04:56 am »
This works but has one small problem for me. If "Check Stock?" is selected in the admin/checkout the "Add to Cart button" shows "Notify me" even though there is plenty of stock (for all products in the category)

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10293
  • VirtueMart Version: 3+
Re: Add the "add to cart" button to the category view [Solved]
« Reply #34 on: November 08, 2011, 12:46:15 pm »
try changing to this

if (VmConfig::get('check_stock') == '1' && !$product->product_in_stock) {
I do NOT do development work for hire.

carbon

  • Beginner
  • *
  • Posts: 22
Re: Add the "add to cart" button to the category view [Solved]
« Reply #35 on: November 09, 2011, 05:59:40 am »
Thank you, that also works, button now correctly shows "Add to Cart" and not "Notify me".

Small problem remains that the + and - buttons next to Add to Cart button count up and down in two's. Guess you could call it an up-sell when they click the +  :)

haonampro

  • Beginner
  • *
  • Posts: 5
Re: Add To Cart From Category [Solved]
« Reply #36 on: November 22, 2011, 14:43:39 pm »
Add To Cart function not solved yet. It active with beez template in joomla 1.7 only.

drizzt99

  • Jr. Member
  • **
  • Posts: 91
Re: Add To Cart From Category [Solved]
« Reply #37 on: November 22, 2011, 19:45:17 pm »
This issue is not solved. Why is it marked as solved?
I see many people have the problem that when adding a product, it adds 2 and not 1...
How can this be solved? I see many people asked it and no developer has an answer - is that a mystery for Mulder and Scully?

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10293
  • VirtueMart Version: 3+
Re: Add To Cart From Category [Solved]
« Reply #38 on: November 22, 2011, 20:23:26 pm »
To fix the quantity problem remove the up and down keys. Leave it as a text box.
Remove

<span class="quantity-controls">
            <input type="button" class="quantity-controls quantity-plus" />
            <input type="button" class="quantity-controls quantity-minus" />
         </span>
I do NOT do development work for hire.

drizzt99

  • Jr. Member
  • **
  • Posts: 91
Re: Add To Cart From Category [Solved]
« Reply #39 on: November 22, 2011, 23:17:38 pm »
To fix the quantity problem remove the up and down keys. Leave it as a text box.
Remove

<span class="quantity-controls">
            <input type="button" class="quantity-controls quantity-plus" />
            <input type="button" class="quantity-controls quantity-minus" />
         </span>

Well... that's a solution I didn't think of... if a feature isn't working, let's throw it away :)

Thanks, but is there a solution that leaves me with this feature? After all, the +/- signs do work at the product details page...

MKI-Miro

  • Jr. Member
  • **
  • Posts: 97
Re: Add To Cart From Category [Solved]
« Reply #40 on: November 30, 2011, 14:50:50 pm »
is this solution working for you when you have SEF enabled ?

lipixx

  • Beginner
  • *
  • Posts: 10
Re: Add To Cart From Category [Solved]
« Reply #41 on: December 01, 2011, 22:39:16 pm »
In order to solve the +2 -2 problem, you must edit the file located under:

/var/www/joomla/components/com_virtuemar/assets/js/vmprices.js

And change the following two lines that you can find at the top of the file:

Change:

                      plus   = cart.find('.quantity-plus'),
                      minus  = cart.find('.quantity-minus'),

with:
                      plus   = cart.find('.quantity-plus').unbind("click"),
                      minus  = cart.find('.quantity-minus').unbind("click"),

http://stackoverflow.com/questions/1536660/jquery-click-event-handler-is-called-twice-for-a-checkbox





EXPLANATIONS ABOUT THE PROBLEMS OF THIS POST:

I don't understand why this feature is not active by default. As some people commented here it is a very useful option and it would be a  check into the  Virtuemart configuration
to enable/disable the fetaure.

Furthermore, I found difficulties reading this post. For this reason I will write this here:

The procedure that you must follow in order to display the "ADD TO CART" button and "QUANTITY" box, when you are viewing a page with virtuemart Categories listed is:

1. Copy with ctrl+c the code of the first post of this thread.
2. Edit the file:  /var/www/joomla/components/com_virtuemart/views/category/tmpl/default.php
3. Insert the copied code between the following lines:

Code: [Select]
<?php // Product Details Button
                        
echo JHTML::link($product->linkJText::_('COM_VIRTUEMART_PRODUCT_DETAILS'),
                         array(
'title' => $product->product_name,'class' => 'product-detail\s'));
                         
?>

                         </p>

PASTE THE CODE HERE!!!!!!!!!!!!!!!!

Code: [Select]
                   </div>
                        <div class="clear"></div>
                        </div>
                </div>
        <?php
        $iBrowseProduct 
++;

        
// Do we need to close the current row now? 


4. Save and close. The buttons will appear.
5. If you try to click on + and - buttons, you will see that the quantity of the product is increasing/decreasing by 2. It's because the click event is passed to the "input" element, and also passed to another element. It makes that the function of clicking gets executed two times. In order to solve this, read the top of this post that deals with modificating the file vmprices.js.




MY TEMPLATE DESIGN PROBLEMS:

I am having problems with the button colors, aspect, etc. I would like to change the button to a smallest and less abusive button, but only in the Categories page. I tried to change the line in the default.php (the one that I modified some lines ago in this post) that says:

Code: [Select]
<input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
Changing the class="addtocart-button" , to "addtocart-button-smaller", and creating a class into the .css file. The button appears as I want, but it does not run.... while I am writing these lines I see the problem. When I click the button the JQuery function that adds the products to the cart does not get executed, because the function is executed only for certain classes. So I see.. I have to modify vmprices.js and I suppose that I have to modify it adding:

addtocart-smaller = cart.find('input.addtocart-button-smaller'),

And adding a function for this:

addtocart-smaller.click(.... identical content of addtocart.click(...) });

Ok!

That's all for me ;)

chadgarber

  • Jr. Member
  • **
  • Posts: 62
    • Garber Consulting, Inc.
Re: Add To Cart From Category [Solved]
« Reply #42 on: January 18, 2012, 17:51:40 pm »
Nice. This did the trick. Thanks for the clarifications.

In order to solve the +2 -2 problem, you must edit the file located under:

/var/www/joomla/components/com_virtuemar/assets/js/vmprices.js

And change the following two lines that you can find at the top of the file:

Change:

                      plus   = cart.find('.quantity-plus'),
                      minus  = cart.find('.quantity-minus'),

with:
                      plus   = cart.find('.quantity-plus').unbind("click"),
                      minus  = cart.find('.quantity-minus').unbind("click"),

http://stackoverflow.com/questions/1536660/jquery-click-event-handler-is-called-twice-for-a-checkbox





EXPLANATIONS ABOUT THE PROBLEMS OF THIS POST:

I don't understand why this feature is not active by default. As some people commented here it is a very useful option and it would be a  check into the  Virtuemart configuration
to enable/disable the fetaure.

Furthermore, I found difficulties reading this post. For this reason I will write this here:

The procedure that you must follow in order to display the "ADD TO CART" button and "QUANTITY" box, when you are viewing a page with virtuemart Categories listed is:

1. Copy with ctrl+c the code of the first post of this thread.
2. Edit the file:  /var/www/joomla/components/com_virtuemart/views/category/tmpl/default.php
3. Insert the copied code between the following lines:

Code: [Select]
<?php // Product Details Button
                        
echo JHTML::link($product->linkJText::_('COM_VIRTUEMART_PRODUCT_DETAILS'),
                         array(
'title' => $product->product_name,'class' => 'product-detail\s'));
                         
?>

                         </p>

PASTE THE CODE HERE!!!!!!!!!!!!!!!!

Code: [Select]
                   </div>
                        <div class="clear"></div>
                        </div>
                </div>
        <?php
        $iBrowseProduct 
++;

        
// Do we need to close the current row now? 


4. Save and close. The buttons will appear.
5. If you try to click on + and - buttons, you will see that the quantity of the product is increasing/decreasing by 2. It's because the click event is passed to the "input" element, and also passed to another element. It makes that the function of clicking gets executed two times. In order to solve this, read the top of this post that deals with modificating the file vmprices.js.




MY TEMPLATE DESIGN PROBLEMS:

I am having problems with the button colors, aspect, etc. I would like to change the button to a smallest and less abusive button, but only in the Categories page. I tried to change the line in the default.php (the one that I modified some lines ago in this post) that says:

Code: [Select]
<input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
Changing the class="addtocart-button" , to "addtocart-button-smaller", and creating a class into the .css file. The button appears as I want, but it does not run.... while I am writing these lines I see the problem. When I click the button the JQuery function that adds the products to the cart does not get executed, because the function is executed only for certain classes. So I see.. I have to modify vmprices.js and I suppose that I have to modify it adding:

addtocart-smaller = cart.find('input.addtocart-button-smaller'),

And adding a function for this:

addtocart-smaller.click(.... identical content of addtocart.click(...) });

Ok!

That's all for me ;)
Chad Garber
Web Developer/Computer Support
770.639.4847
Garber Consulting, Inc.
http://garberconsulting.net

wharfadale

  • Beginner
  • *
  • Posts: 18
Re: Add To Cart From Category [Solved]
« Reply #43 on: January 20, 2012, 14:11:27 pm »
It's Ок
To show some customfields of product not related to cart on category page we can use this code
Code: [Select]
<?php // Product custom_fields
if (!empty($product->customfields)) {  ?>

<div class="product-fields">
<?php foreach ($product->customfields as $field)
?>
<div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field_type ?>">
<span class="product-fields-title" ><b><?php echo  JText::_($field->custom_title?></b></span>
<?php echo JHTML::tooltip($field->custom_tip,  JText::_($field->custom_title), 'tooltip.png'); ?>
<span class="product-field-display"><?php echo $field->display ?></span>

<span class="product-field-desc"><?php echo $field->custom_field_desc ?></span>
</div><br/ >
<?php
}
?>

</div>
<?php ?>

I use this solution. Thanks! :)
But there is one problem - if parameter is Cart attribute it's not displayed.
How can i show custom fields which aren't cart attribute in the cart? Or how to show custom fields (cart attribute) with code above?

aki

  • Beginner
  • *
  • Posts: 13
Re: Add To Cart From Category [Solved]
« Reply #44 on: February 15, 2012, 16:50:42 pm »
does not work for me exactly what to change, which file or perhaps a modified file can not ask someone  :-[ :-[
thank you