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

legal

  • Beginner
  • *
  • Posts: 13
    • Parfumi
Re: Add the "add to cart" button to the category view [Solved]
« Reply #15 on: September 21, 2011, 23:39:29 pm »
I also have the same problem as stated above. Also if you add a product in the category view I only get the message: "1 undefined was added to your cart" Not the product name

Have you try code which I paste few posts higher?

Otherwise  this have to work:
Code: [Select]
<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 $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' && !$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>

Awerso

  • Jr. Member
  • **
  • Posts: 67
Re: Add the "add to cart" button to the category view [Solved]
« Reply #16 on: October 02, 2011, 15:52:50 pm »
Another small problem is that when you click on the button to add a product, instead of adding only one product, it adds two at a time (if you have 1 and click on the add button, the counter goes directly to 3 instead of 2 and then 5, 7, etc.)

Is there already a solution for that?

aaronf

  • Beginner
  • *
  • Posts: 24
Re: Add the "add to cart" button to the category view [Solved]
« Reply #17 on: October 11, 2011, 05:39:16 am »
This is a great thread. Now, I have to apologize because I'm a PHP noob... I can't figure out where to insert legal's code, can anyone give me a specific location? Thanks...

Aaron

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10278
  • VirtueMart Version: 3+
Re: Add the "add to cart" button to the category view [Solved]
« Reply #18 on: October 11, 2011, 12:55:29 pm »
do you mean what file? or what part of the file?

I do NOT do development work for hire.

aaronf

  • Beginner
  • *
  • Posts: 24
Re: Add the "add to cart" button to the category view [Solved]
« Reply #19 on: October 11, 2011, 15:48:14 pm »
I assumed it needed to go in the category view default.php, so I just need to know where in the file. Thanks.

Aaron

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10278
  • VirtueMart Version: 3+
Re: Add the "add to cart" button to the category view [Solved]
« Reply #20 on: October 11, 2011, 16:38:32 pm »
that part is your choice. WHERE do you want it?
I do NOT do development work for hire.

aaronf

  • Beginner
  • *
  • Posts: 24
Re: Add the "add to cart" button to the category view [Solved]
« Reply #21 on: October 11, 2011, 17:35:08 pm »
Well, thus far nothing I've tried has worked, so I don't know what I'm doing wrong.

Aaron

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10278
  • VirtueMart Version: 3+
Re: Add the "add to cart" button to the category view [Solved]
« Reply #22 on: October 11, 2011, 18:07:22 pm »
RIGHT UNDER THIS
<p>
               <?php // Product Details Button
               echo JHTML::link($product->link, JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name,'class' => 'product-details'));
               ?>
               </p>


and make sure to use the code from this post
http://forum.virtuemart.net/index.php?topic=90961.msg298793#msg298793
I do NOT do development work for hire.

Awerso

  • Jr. Member
  • **
  • Posts: 67
Re: Add the "add to cart" button to the category view [Solved]
« Reply #23 on: October 11, 2011, 22:39:06 pm »
Another small problem is that when you click on the button to add a product, instead of adding only one product, it adds two at a time (if you have 1 and click on the add button, the counter goes directly to 3 instead of 2 and then 5, 7, etc.)

Anyone with a solution for that bug?

aaronf

  • Beginner
  • *
  • Posts: 24
Re: Add the "add to cart" button to the category view [Solved]
« Reply #24 on: October 14, 2011, 01:33:52 am »
Banquet,
I hate to be a pain, but that code in that location didn't work for me. Nothing changed. And I made sure that my default category view as well as my individual categories were set right... I don't get it.

Aaron

charles99

  • Jr. Member
  • **
  • Posts: 61
Re: Add the "add to cart" button to the category view [Solved]
« Reply #25 on: November 01, 2011, 19:15:37 pm »
Why isn't this a built in feature?   Its in 1.1.9 so why force people to add it now?  And from the reply no one seem to know what file or where to place the changes!  In virtuemeart it just worked so when you click on a category item it showed you all the products in that category with its prices, and a add to cart button.  But in VM2.0 you are forcing users to add this feature. 

Come on guy add the feature to the program already...

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10278
  • VirtueMart Version: 3+
Re: Add the "add to cart" button to the category view [Solved]
« Reply #26 on: November 01, 2011, 21:00:54 pm »
charles, not many people at all used vmart the way it came right out of the box.
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 #27 on: November 02, 2011, 16:50:18 pm »
350 people that I have directed to VM 1.1.5 to VM 1.1.9 do!  And all I am saying it this, there has to be a carryover process that people know if you want them to continue  to use VM and grow its base.   And I know with every new version there will be new features or old one deleted but asking people to add codes and not knowing where to add them only leads to problems...


Take a look at this post, I am not sure if the fix works!  Or it worked for one or two people and not for the others that submitted a post stating the factor that it didn't work. Or ran into another problem when it came to adding a product.

So I would like to know which code I need to add to the default.php file in order to show the add to cart button on the category detail page?   And beta or RC should never be used as an excuse for bad coding or a lack of detail.    And yet me just say I am not saying there is any bad coding going on here!  I know VM2.0 still an RC program but please keep in mind why people download this program or component?  Everyone is chasing a dream to work for themself.  Provide a service to a consumer that only they can and it is those little bumps in the road that can kill a person dreams, especially when they don't know the basic features of VM or how to edit a php file...   when you read some of the posts in the forum you can see there is a lot of people working day and night trying to get a handle on VM2.0 even with all of the bugs.  And only by working together can we as a community solved them, or allow alot of newbies get some much needed sleep! I know I can use a bit of sleep after another all night-er of trying to get VM2.0 and my other JS to work.  So if you can tell me what code I need to add to the Default.php it will save me a couple hours of stirring at the computer screen...

So let me thank you in advance for the help and work you have put into this component.  And just keep mind the little guy, thats out there pulling out their hair trying to learn how VM 2.0 works...






 


PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10278
  • VirtueMart Version: 3+
Re: Add the "add to cart" button to the category view [Solved]
« Reply #28 on: November 02, 2011, 17:05:39 pm »
http://forum.virtuemart.net/index.php?topic=90961.msg301855#msg301855

Code: [Select]
<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
<?php // Product custom_fields
if (!empty($this->product->customfieldsCart)) {  ?>

<div class="product-fields">
<?php foreach ($this->product->customfieldsCart 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 }
 /* Product custom Childs
  * to display a simple link use $field->virtuemart_product_id as link to child product_id
  * custom_value is relation value to child
  */

if (!empty($this->product->customsChilds)) {  ?>

<div class="product-fields">
<?php foreach ($this->product->customsChilds as $field) {  ?>
<div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field->field_type ?>">
<span class="product-fields-title" ><b><?php echo JText::_($field->field->custom_title?></b></span>
<span class="product-field-desc"><?php echo JText::_($field->field->custom_value?></span>
<span class="product-field-display"><?php echo $field->display ?></span>

</div><br/ >
<?php
?>

</div>
<?php ?>

<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>
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 #29 on: November 02, 2011, 18:00:13 pm »
I am running into the same problem everyone else is?  When you click on the add to cart button it adds two items to the cart.  For some odd reason its forces you to click twice on the add to cart button before anything shows in the cart.  But when you click once and then refresh the page the product shows!   But I do see why two items or products are being added to the cart.

Does anyone know how we can get the item to show on one click?   Again when you click on the add to cart button once nothing show in the cart, only when you click a couple of times does the item show in the cart, but its adds both clicks.   Also when you click once on the add to cart button then refresh the page just one item or product is added to the cart.

again the first click on the add to cart button is not showing in the cart, and I need to know how can we fix this?

Thanks