News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Adding product customfields to the category page

Started by lupinlady, February 21, 2014, 23:07:30 PM

Previous topic - Next topic

lupinlady

First I want to apologize for posting this again. I posted this to an old topic that was closed already and really need help with this. Im new to php.

Im trying to get the customfields area from the details page on to the category page. The Add to Cart button was already there, came with the template. Ive tried a couple of suggestions from this forum and still no luck.
Some of the things Ive tried:

I edited /hot_watches/html/com_virtuemart/category/default.php  Since the 'Add to Cart' button was hard coded in I copied the code from /components/com_virtuemart/views/productdetails/tmpl/default_customfields.php and added it above the cart button. First I added the 'custom fields position above the 'product fields' but it didnt work so I moved it below, still not working. Then changed$this->product to $product and I also removed the part -- echo $this->loadTemplate ('customfields' ); -- since the template is already there.

On the next try I added default_customfields.php to the category folder renamed as default_customfields_category.php and tried an include per some of the suggestions on this site. This came from a topic on the add to cart button but I applied it to the customfields.

Not sure what else to try. Any help would be great. Also, just a suggestion, as an upgrade to the next version of Virtuemart, could the customfields and the add to cart button be a module that could be placed on any page? Or something in the VM admin area that selects which pages it is to appear on? Like a menu item?

The code I tried first is below: Ive added comments as to what Ive added or changed.

// Show Products
   ?>
   <div class="product floatleft<?php echo $Browsecellwidth . $show_vertical_separator ?>">
   <div class="spacer">

   <div class="product_intro">

   <h3 style="float:left;"><a href="javascript:;">
   <?php // Product Name
      echo $product->product_name; ?>
      </a></h3>
      <div style="float:right;" class="rotated_image">
      <a title="<?php echo $product->link ?>" rel="vm-additional-images" href="<?php echo $product->link; ?>">
   <?php
      echo $product->images[0]->displayMediaThumb('class="browseProductImage"', false);
   ?>
   </a>
   </div>
   <div class="clr"></div>
   </div>

   <div class="product_details_box">
               
   <div class="normal_image">
   <?php if ($product->images) {
   echo JHTML::_ ( 'link', JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id ), $product->images[0]->displayMediaThumb( 'class="featuredProductImage" border="0"',false,'class="modal"' ) );
   } ?>
   </div>
                   
   <div class="product_details_box2">
   <div class="product_details_box3">
   <?php // Product Short Description
   if (!empty($product->product_desc)) {
   ?>
   <p class="product_s_desc">
      <?php echo shopFunctionsF::limitStringByWord ($product->product_desc, 1000, '...') ?>
   </p>
   <?php } ?>
                               
<!-- I copied the 'product fields' from /components/com_virtuemart/views/productdetails/tmpl/default_customfields.php and placed it here -->                           
                                                               
   <div class="product-fields">
      <?php
        $custom_title = null;
        foreach ($product->customfieldsSorted[$this->position] as $field) {
        if ( $field->is_hidden ) //OSP http://forum.virtuemart.net/index.php?topic=99320.0
        continue;
        if ($field->display) {
      ?><div class="product-field product-field-type-<?php echo $field->field_type ?>">
      <?php if ($field->custom_title != $custom_title && $field->show_title) { ?>
      <span class="product-fields-title" ><?php echo JText::_($field->custom_title); ?></span>
      <?php
        if ($field->custom_tip)
        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 jText::_($field->custom_field_desc) ?></span>
        </div>
      <?php
        $custom_title = $field->custom_title;
         }
          }
      ?>
      </div>
<!-- I copied the 'custom fields position' from /templates/hot_watches/html/com_virtuemart/productdetails/default.php --->           
      <div>
        <?php
      if (!empty($product->customfieldsSorted['normal'])) {
      $this->position = 'normal';
       }
    ?>
     </div>
   <div style="padding:20px 0;">   
   <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>