VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: lgiulio on November 29, 2015, 11:18:19 AM

Title: Add cart in the category
Post by: lgiulio on November 29, 2015, 11:18:19 AM
Should I put the cart button in the categories.

I tried to add the code to the file :/components/com_virtuemart/views/category/tmpl/default.php

Code:

<form method="post" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
    <?php // Product custom_fields
  if (!empty($this->product->customfieldsCart)) { ?>
       <div>
    <?php foreach ($this->product->customfieldsCart as $field)
             { ?><div style="display:inline-block;"color: rgb(0, 0, 0);"><?php echo $field->field_type ?>">
          <span ><b><?php echo JText::_($field->custom_title) ?></b></span>
       <?php echo JHTML::tooltip($field->custom_tip, JText::_($field->custom_title), 'tooltip.png'); ?>
          <span><?php echo $field->display ?></span>

      <span><?php echo $field->custom_field_desc ?></span>
   </div><br/ >
       <?php
        }
             ?>
      </div>
<?php }
  // Product custom Childs
if (!empty($this->product->customsChilds)) { ?>
   <div>
     <?php foreach ($this->product->customsChilds as $field) { ?>
       <div style="display:inline-block;"color: rgb(0, 0, 0);"><?php echo $field->field->field_type ?>">
          <span ><b><?php echo JText::_($field->field->custom_title) ?></b></span>
       <span><?php echo JText::_($field->field->custom_value) ?></span>
     <span><?php echo $field->display ?></span>

       </div><br/ >
        <?php
             } ?>
     </div>
<?php } ?>
  <div>
          <?php // Display the quantity box ?>
     <!-- <label for="quantity<?php echo $this->product->virtuemart_product_id;?>"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
   <span>
       <input type="text" name="quantity[]" value="1" />
         </span>
          <span>
          <input type="button" />
           <input type="button" />
         </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>
           <input type="submit" name="addtocart" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
       </span>
     <div></div>
         </div>
      <?php // Display the add to cart button END ?>
  <input type="hidden" 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>


but not working


Thanks
Title: Re: Add cart in the category
Post by: jenkinhill on November 29, 2015, 13:13:17 PM
Please:  http://forum.virtuemart.net/index.php?topic=128401.0

Add to cart with the category layout is already built into VM3. See http://demo.virtuemart.net/headpiece
Title: Re: Add cart in the category
Post by: lgiulio on November 29, 2015, 17:00:03 PM
use the version of virtuemart 3.0.8

Joomla  3.4.1

Templates commercial

I have to change some settings?

Thank you
Title: Re: Add cart in the category
Post by: jenkinhill on November 29, 2015, 18:03:56 PM
You are using insecure Joomla & VM versions. http://forum.virtuemart.net/index.php?topic=118683.0

Check updates on a backup copy of the site. If add to cart does not show on category page, change Joomla template to Protostar. If add to cart now shows then ask your template supplier why it does not work on the one you were sold.