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

Please Help! Call to a member function get() in html/com_virtuemart/category/def

Started by jessdaddy, December 12, 2013, 04:49:33 AM

Previous topic - Next topic

jessdaddy

Hi. I am new to VM, but have been plugging along and managed to overcome most of the problems i have had with a template i purhcased. Nevertheless, I am having problems with the "Search" and "Shop NOw" cart functions on the front page. Whenever i click the Cart button labeled "Shop Now" it returns the following error:

Fatal error: Call to a member function get() on a non-object in /home/jeff/public_html/templates/esw_easypeasy/html/com_virtuemart/category/default.php on line 70

Same error occurs if I search for something in the Search box

Now, if I add a product to the cart the blue "Shop Now" button turns green and label turns to "Go to Checkout" (which is normal After the label and color of the button change, I can click it  proceed to the checkout page.

I have searched all sorts of solutions for similar Call to a Member Function errors, and none seem to solve my problem.

Does anyone have any idea how I can fix this.

Site is www.sakto.net

Here are the contents of the Default.php file referenced in the error :( if it helps):

THank you very much in advance:


<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

// LOAD EASY CONFIG
require_once ('templates/esw_easypeasy/html/com_virtuemart/easy_configuration.php');

//LOAD Easyvirtuemart plugin config
$easyVmPlugin = JPluginHelper::getPlugin('system', 'easyvirtuemart');
$easyParams = new JRegistry($easyVmPlugin->params);

//vmdebug('$this->category',$this->category);
vmdebug ('$this->category ' . $this->category->category_name);
// Check to ensure this file is included in Joomla!
defined ('_JEXEC') or die('Restricted access');
//JHTML::_ ('behavior.modal');
/* javascript for list Slide
  Only here for the order list
  can be changed by the template maker
*/
$js = "
jQuery(document).ready(function () {
   jQuery('.orderlistcontainer').hover(
      function() { jQuery(this).find('.orderlist').stop().show()},
      function() { jQuery(this).find('.orderlist').stop().hide()}
   )
});
";

$document = JFactory::getDocument ();
$document->addScriptDeclaration ($js);

/*$edit_link = '';
if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
if (Permissions::getInstance()->check("admin,storeadmin")) {
   $edit_link = '<a href="'.JURI::root().'index.php?option=com_virtuemart&tmpl=component&view=category&task=edit&virtuemart_category_id='.$this->category->virtuemart_category_id.'">
      '.JHTML::_('image', 'images/M_images/edit.png', JText::_('COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT'), array('width' => 16, 'height' => 16, 'border' => 0)).'</a>';
}

echo $edit_link; */
$config =& JFactory::getConfig();

$virtuemart_category_id = JRequest::getVar('virtuemart_category_id');

if($virtuemart_category_id == 0)
{
    $menu = &JSite::getMenu();
    $active = $menu->getActive();
    $menuname = $active->params->get('page_heading');
    echo '<h1 class="page-header">'.$menuname.'</h1>';
}           
if (empty($this->keyword)) {
?>
   <?php if(!empty($this->category->category_name)) echo '<h1 class="page-header">'.$this->category->category_name.'</h1>'; ?>
   
   <?php if(!empty($this->category->category_name)){?>
   <div class="category_description lead">
      <?php echo $this->category->category_description; ?>
   </div>
<?php
   }
}

/* Show child categories */

if (VmConfig::get ('showCategory', 1) and empty($this->keyword)) {
   if ($this->category->haschildren) {
      // Category and Columns Counter
      $iCol = 1;
      $iCategory = 1;
      // Calculating Categories Per Row
      $categories_per_row = VmConfig::get ('categories_per_row', 3);
      $category_span = floor (12 / $categories_per_row);
      //$category_cellwidth = ' width' . floor (100 / $categories_per_row);
      // Separator
      $verticalseparator = " vertical-separator";
      ?>

      <div class="category-view">

      <?php // Start the Output
      if (!empty($this->category->children)) {
         echo '<div class="categories">';
         foreach ($this->category->children as $category) {

            // Show the horizontal seperator
            if ($iCol == 1 && $iCategory > $categories_per_row && false) {
               ?>
               <div class="horizontal-separator"></div>
               <?php
            }

            // this is an indicator wether a row needs to be opened or not
            if ($iCol == 1) {
               ?>
         <div class="row-fluid">
         <?php
            }
            // Show the vertical seperator
            if ($iCategory == $categories_per_row or $iCategory % $categories_per_row == 0) {
               $show_vertical_separator = ' ';
            } else {
               $show_vertical_separator = $verticalseparator;
            }
            // Category Link
            $caturl = JRoute::_ ('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id);

            // Show Category
            ?>
            <div class="category span<?php echo $category_span //. $show_vertical_separator ?>">
               <div class="spacer">
                  <h2>
                     <a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
                        <?php echo $category->category_name ?>
                        <br />
                        <?php // if ($category->ids) {
                        echo $category->images[0]->displayMediaThumb ("", FALSE);
                        //} ?>
                     </a>
                  </h2>
               </div>
            </div>
            <?php
            $iCategory++;

            // Do we need to close the current row now?
            if ($iCol == $categories_per_row) {
               ?>
               <div class="clear"></div>
      </div>
         <?php
               $iCol = 1;
            } else {
               $iCol++;
            }
         }
      echo '</div>';
      }
      // Do we need a final closing row tag?
      if ($iCol != 1) {
         ?>
         <div class="clear"></div>
      </div>
   <?php } ?>
   </div>

   <?php
   }
}
?>
<div class="browse-view">
<?php
if (!empty($this->keyword)) {
   ?>
<h1 class="page-header"><?php echo JText::_ ('COM_VIRTUEMART_SEARCH') ?> <small class="pull-right subheading"><em>"<?php echo $this->keyword; ?>"</em></small></h1>
   <?php
} ?>
<?php if ($this->search !== NULL) { ?>
<form action="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=category&limitstart=0&virtuemart_category_id=' . $this->category->virtuemart_category_id); ?>" method="get">

   <!--BEGIN Search Box -->
   <div class="virtuemart_search">
      <?php echo $this->searchcustom ?>
      <br />
      <?php echo $this->searchcustomvalues ?>
      <input name="keyword" class="inputbox" type="text" size="20" value="<?php echo $this->keyword ?>"/>
      <input type="submit" value="<?php echo JText::_ ('COM_VIRTUEMART_SEARCH') ?>" class="button" onclick="this.form.keyword.focus();"/>
   </div>
   <input type="hidden" name="search" value="true"/>
   <input type="hidden" name="view" value="category"/>
</form>
<!-- End Search Box -->
   <?php } ?>

<?php // Show child categories
if (!empty($this->products)) {
   ?>
<div class="orderby-displaynumber navbar hidden-xs">
   <div class="navbar-inner">
   <div class="pull-left">
       <?php if($this->orderByList['orderby']) { ?>
         <span>
         <?php    
            //Change product order control to dropdown
            //original - $this->orderByList['orderby']
            $orderByList = new DOMDocument;
            $orderByList->loadHTML('<?xml encoding="UTF-8">' .$this->orderByList['orderby']);         
            
            $xpath = new DOMXpath($orderByList);
            $titles = $xpath->query("//div[@class='title']");   
            $links = $xpath->query("//a");
   
            foreach ($titles as $title)
            {
               echo '<span>'.$title->nodeValue.': </span>';
            }
   
            echo '<select onchange="window.location.assign(this.value)">';
   
            if($links->length > 0)
            {      
               foreach ($links as $key => $link)
               {
                  if($key == 0)
                  {
                     $changeOrderLink = $link->getAttribute('href');
                     $link->nodeValue = str_replace("+/-"," - &#8593;",$link->nodeValue);
                     $link->nodeValue = str_replace("-/+"," - &#8595;",$link->nodeValue);
                  }
   
                  echo '<option value="'.$link->getAttribute('href').'">'.$link->nodeValue.'</option>';
               }                  
            }
            else
            {
               $emptys = $xpath->query("//div[@class='Order']");
               foreach ($emptys as $empty)
               {
                  echo '<option>'.$empty->nodeValue.'</option>';
               }
            }   
            echo '</select>';         
         ?>
         </span>
      <?php
         echo '<a style="display:inline-block; padding-left: 9px;padding-right: 9px;" class="btn" href="'.$changeOrderLink.'" ><i class="icon-resize-vertical"></i></a>';
      }
      ?>
      <span>
      <?php
      if($this->orderByList['manufacturer']) {
         //Change mafufacturer filter control to dropdown 
          //original - $this->orderByList['manufacturer']         
         $orderByList->loadHTML($this->orderByList['manufacturer']);
         $orderByList->loadHTML('<?xml encoding="UTF-8">' .$this->orderByList['manufacturer']);
         $links = $orderByList->getElementsByTagName('a');
         $xpath = new DOMXpath($orderByList);
         $titles = $xpath->query("//div[@class='title']");
         
         $manufHTML = '';
         $manufShow = false;   
         foreach ($titles as $title)
         {
            $manufHTML .= '<span>'.$title->nodeValue.'</span>';
         }
          
         $manufHTML .= '<select onchange="window.location.assign(this.value)">';
         if($links->length > 0)
         {                  
             $manufShow = true;
            foreach ($links as $key => $link)
            {
               $manufHTML .= '<option value="'.$link->getAttribute('href').'">'.$link->nodeValue.'</option>';
            }                     
         }
         else
         {               
            $emptys = $xpath->query("//div[@class='Order']");
            
            foreach ($emptys as $empty)
            {
               $manufShow = true;
               $manufSingle = $empty->nodeValue;
               $manufHTML .= '<option>'.$empty->nodeValue.'</option>';
            }
         }
         $manufHTML .= '</select>';      

         if($manufShow == true) echo $manufHTML;
         
      }   
      ?>
         </span>
   </div>
   <span class="pull-right display-number"><?php echo $this->vmPagination->getResultsCounter ();?><?php echo $this->vmPagination->getLimitBox (); ?></span>

   <div class="clear"></div>
   </div>
</div> <!-- end of orderby-displaynumber -->
   <?php
   // Category and Columns Counter
   $iBrowseCol = 1;
   $iBrowseProduct = 1;

   // Calculating Products Per Row
   $BrowseProducts_per_row = $this->perRow;
   $Browsecellwidth = ' span' . floor (12 / $BrowseProducts_per_row);

   // Separator
   $verticalseparator = " vertical-separator";

   // Count products ?? why not just count ($this->products)  ?? note by Max Milbers
   $BrowseTotalProducts = 0;
   foreach ($this->products as $product) {
      $BrowseTotalProducts++;
   }

   // Start the Output
   foreach ($this->products as $product) {

      // Show the horizontal seperator
      if ($iBrowseCol == 1 && $iBrowseProduct > $BrowseProducts_per_row) {
         ?>
      <div class="horizontal-separator"></div>
         <?php
      }

      // this is an indicator wether a row needs to be opened or not
      if ($iBrowseCol == 1) {
         ?>
   <div class="row-fluid">
   <?php
      }

      // Show the vertical seperator
      if ($iBrowseProduct == $BrowseProducts_per_row or $iBrowseProduct % $BrowseProducts_per_row == 0) {
         $show_vertical_separator = ' ';
      } else {
         $show_vertical_separator = $verticalseparator;
      }

      // Show Products
      ?>
      <?php
      //Native VM products per row - disabled
      if (false) { ?>
      <div class="product floatleft<?php echo $Browsecellwidth . $show_vertical_separator ?>">
      <?php } ?>
      
      <div class="product<?php echo $Browsecellwidth;?>">
      
         <div class="spacer">
         
         
         
            <h2><?php echo JHTML::link ($product->link, $product->product_name, 'title="'.str_replace('"','\'',$product->product_name).'"'); ?></h2>
               
               <div class="width100 center browse-image-wrapper">
                  
                  <?php
                  if (file_exists(JPATH_ROOT .DS. 'plugins' .DS. 'system' .DS. 'vmtopandlast' .DS. 'script_category.php'))
                  {
                     include(JPATH_ROOT .DS. 'plugins' .DS. 'system' .DS. 'vmtopandlast' .DS. 'script_category.php' );
                  }
                  ?>
                  
                  <div class="browse-image">                                     
                  <a title="<?php echo $product->product_name ?>" href="<?php echo $product->link; ?>">
                     <?php
                        $imageSize = getimagesize ( JPATH_ROOT.DS.$product->images[0]->file_url_thumb );
                        echo $product->images[0]->displayMediaThumb($imageSize[3].' class="browseProductImage" title="'.$product->product_name.'"', false);
                     ?>
                   </a>
                       </div>
                  <!-- The "Average Customer Rating" Part -->
                  <?php if ($this->showRating) { ?>
                  <span class="contentpagetitle"><?php echo JText::_ ('COM_VIRTUEMART_CUSTOMER_RATING') ?>:</span>
                  <br />
                  <?php
                  // $img_url = JURI::root().VmConfig::get('assets_general_path').'/reviews/'.$product->votes->rating.'.gif';
                  // echo JHTML::image($img_url, $product->votes->rating.' '.JText::_('COM_VIRTUEMART_REVIEW_STARS'));
                  // echo JText::_('COM_VIRTUEMART_TOTAL_VOTES').": ". $product->votes->allvotes;
                  ?>
                  <?php } ?>
                   <?php
                  if ( VmConfig::get ('display_stock', 1)) { ?>
                  <!--                   if (!VmConfig::get('use_as_catalog') and !(VmConfig::get('stockhandle','none')=='none')){?> -->
                  <div class="paddingtop8">
                     <span class="vmicon vm2-<?php echo $product->stock->stock_level ?>" title="<?php echo $product->stock->stock_tip ?>"></span>
                     <span class="stock-level"><?php echo JText::_ ('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP') ?></span>
                  </div>
                  <?php }?>
            </div>
            <?php if(JFile::exists(JPATH_ROOT.'/plugins/system/easyupdate/easyupdate.php')) { ?>
            <?php echo '{easyupdatetags '.$product->virtuemart_product_id.'}';  ?>
            <?php } ?>
            <div class="width100 floatright">


               <?php // Product Short Description
               if (!empty($product->product_s_desc)) {
                  ?>
                  <p class="product_s_desc">
                     <?php echo shopFunctionsF::limitStringByWord (strip_tags($product->product_s_desc), $productShortDescLimit, '...') ?>
                  </p>
                  <?php } ?>

               <div class="product-price marginbottom12" id="productPrice<?php echo $product->virtuemart_product_id ?>">
               
                  <?php echo '{price '.$product->virtuemart_product_id.'}';  ?>               
               
<?php
                  

?>

               </div>
                     
            
               {stock <?php echo $product->virtuemart_product_id ?>}                

               <?php 
               $showAddToCart = (bool)$easyParams->get('showAddToCart');
               $hideAddToCartIfFree = (bool)$easyParams->get('hideAddToCartIfFree');
               if($hideAddToCartIfFree and $product->prices['basePrice'] == 0 )
               {
                  $showAddToCart = false;
               }
               
               if($showAddToCart)
               { ?>             
               <div class="btn-group buttons">
               
                  <form method="post" class="product btn btn-warning" action="index.php">
                        
                     <div class="addtocart-bar">
         
                        <?php
                        // Add the button
                        $button_lbl = JText::_ ('COM_VIRTUEMART_CART_ADD_TO');
                        $button_cls = ''; //$button_cls = 'addtocart_button';
      
      
                        ?>
                        <?php // Display the add to cart button ?>
                        <div class="addtocart-button icon-shopping-cart">
                           <input type="submit" name="addtocart" class="addtocart-button " value="" title="">
                           <?php // echo shopFunctionsF::getAddToCartButton($product->orderable); ?>
                        </div>
                                    
                     </div>
                          <input type="hidden" class="quantity-input" name="quantity[]" value="1"/>
                     <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_category_id[]" value="<?php echo $product->virtuemart_category_id ?>"/>
                  </form>

                  <?php // Product Details Button
                  echo JHTML::link ($product->link, JText::_ ('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name, 'class' => 'product-details btn btn-warning'));
                  ?>
               </div>
               <?php
               }
               else
               { ?>
                      <div class="buttons">
                     <?php // Product Details Button
                     echo JHTML::link ($product->link, JText::_ ('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name, 'class' => 'product-details btn btn-warning'));
                     ?>
                   </div>
               <?php
               }
               ?>
            </div>
            <div class="clear"></div>
         </div>
         <!-- end of spacer -->
      </div> <!-- end of product -->
      <?php

      // Do we need to close the current row now?
      if ($iBrowseCol == $BrowseProducts_per_row || $iBrowseProduct == $BrowseTotalProducts) {
         ?>
         <div class="clear"></div>
   </div> <!-- end of row -->
         <?php
         $iBrowseCol = 1;
      } else {
         $iBrowseCol++;
      }

      $iBrowseProduct++;
   } // end of foreach ( $this->products as $product )
   // Do we need a final closing row tag?
   if ($iBrowseCol != 1) {
      ?>
   <div class="clear"></div>

      <?php
   }
   ?>

<div class="vm-pagination pagination"><?php echo $this->vmPagination->getPagesLinks (); ?><span style="float:right"><?php echo $this->vmPagination->getPagesCounter (); ?></span></div>

   <?php
} elseif ($this->search !== NULL) {
   echo JText::_ ('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ? ' : (' . $this->keyword . ')' : '');
}
?>
</div><!-- end browse-view -->
<script type="text/javascript">
jQuery('.vm-pagination a').each(function(e) {
         jQuery(this).attr('href', jQuery(this).attr('href')+'&search=true');
});
</script>


GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum