VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: aseermrmr on February 20, 2020, 07:19:26 AM

Title: Showing SKU in Products descriptions
Post by: aseermrmr on February 20, 2020, 07:19:26 AM
Hi , i am really sorry for keep asking
i was searching for the problem before i post this topic
nothing show how to do it with step by step , or where to post the code
i want to show the SKU under the price in the products page as this attachment
any help with that please and explain where to drop the code
thanks in advance
Title: Re: Showing SKU in Products descriptions
Post by: GJC Web Design on February 20, 2020, 09:17:56 AM
details

echo '<div id="skudiv">SKU: '.$this->product->product_sku.' </div>';

cat view

echo '<div class="skudiv">SKU: '.$product->product_sku.'</div>';

where depends entirely on your template but obviously in the default.php of the over rides
Title: Re: Showing SKU in Products descriptions
Post by: aseermrmr on February 20, 2020, 12:21:01 PM
thank you so much sir

where to insert it , in what line ?
i am new with coding :)
i saw this word ( over rides ) what dose this mean ?
and what is the directory for this file default.php is it the the template or on the main component

thank you so much for helping me 
Title: Re: Showing SKU in Products descriptions
Post by: aseermrmr on February 20, 2020, 12:46:44 PM
i managed to know how is the overide work
and i have added that code and it looks now like this

6BTA Piston
Sales price $25.00
'
SKU: '.$this->product->product_sku.'
';

Product Description
Cummins 4BTA 6BTA 3802100

http://www.depqs.com/index.php/left-menue/cummins/6bta-piston-2-detail

what is the wrong
here is the code :

<div class="ttr_prodes_Price">
<?php     
    // Product Price started    
    echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$this->product,'currency'=>$this->currency));
    // Product Price Ends
    ?>

</div>
'<div id="skudiv">SKU: '.$this->product->product_sku.' </div>';
<?php
Title: Re: Showing SKU in Products descriptions
Post by: aseermrmr on February 20, 2020, 12:50:45 PM
i fix it with this code
<?php echo $this->product->product_sku ?>

really thank you so much sir
Title: Re: Showing SKU in Products descriptions
Post by: aseermrmr on February 20, 2020, 13:02:51 PM
but sir where i can find the next one as this picture
i don't know in what file
Title: Re: Showing SKU in Products descriptions
Post by: Studio 42 on February 20, 2020, 13:27:27 PM
IN /components/com_virtuemart/sublayouts/products.php
You can override in template too  /templates/yourtemplate/html/com_virtuemart/sublayouts/products.php
Title: Re: Showing SKU in Products descriptions
Post by: aseermrmr on February 20, 2020, 13:31:31 PM
yes i did that but the site didn't work after my change
where i should insert it ?
i want it after the products name

can you help me to change it

here is my code :

Quote<?php
defined('_JEXEC') or die('Restricted access');
$products_per_row = $viewData['products_per_row'];
$app = JFactory::getApplication();
$template_path = JPATH_BASE . "/templates/" . $app->getTemplate().'/params.ini';
$ini_array = parse_ini_file($template_path);
$addtocart = $ini_array['addtocartbuttonindex'];
$products_per_row = $viewData['products_per_row'];
if( $products_per_row > 0 )
{
$lg = $products_per_row;
$sm = $products_per_row;
$xs = 1;
}else
{
$lg = 4;
$sm = 4;
$xs = 1;
}
$class_suffix_lg  = round((12 / $lg));
$class_suffix_sm  = round((12 / $sm));
$class_suffix_xs  = round((12 / $xs));
$currency = $viewData['currency'];
$showRating = $viewData['showRating'];
$verticalseparator = "vertical-separator";
echo shopFunctionsF::renderVmSubLayout('askrecomjs');
$ItemidStr = '';
$Itemid = shopFunctionsF::getLastVisitedItemId();
if(!empty($Itemid)){
   $ItemidStr = '&Itemid='.$Itemid;
}
foreach ($viewData['products'] as $type => $products ) {
   $rowsHeight = shopFunctionsF::calculateProductRowsHeights($products,$currency,$products_per_row);
   if(!empty($type) and count($products)>0){
      $productTitle = vmText::_('COM_VIRTUEMART_'.strtoupper($type).'_PRODUCT'); ?>
      <div class="<?php echo $type ?>-view">
        <h4><?php echo $productTitle ?></h4>
   <?php
   
    }
   $cellwidth = ' width'.floor ( 100 / $products_per_row );
   $BrowseTotalProducts = count($products);
   $col = 1;
   $nb = 1;
   $row = 1;
   $columncounter = 0;
   foreach ( $products as $product ) {
   if ($col == 1 && $nb > $products_per_row) { ?>   
   <div class="horizontal-separator"></div>
      <?php }
         if ($col == 1) { ?>
      <div class="row">
         <?php }
         if ($nb == $products_per_row or $nb % $products_per_row == 0) {
            $show_vertical_separator = ' ';
         } else {
            $show_vertical_separator = $verticalseparator;
         }
    ?>       
   <div class="col-lg-<?php echo $class_suffix_lg;?> col-md-<?php echo $class_suffix_lg;?> col-sm-<?php echo $class_suffix_sm;?> col-xs-<?php echo $class_suffix_xs;?>">
      <article class="ttr_post">
         <div class="ttr_post_content_inner">
         <div class="ttr_article grid">
         
      <a title="<?php echo $product->product_name ?>" href="<?php echo $product->link.$ItemidStr; ?>" class="product-image">
      <?php echo $product->images[0]->displayMediaThumb('', false); ?>
      </a> 
      <div class="product-shop">
         <div class="product-shop-margin postcontent">
            <div class="ttr_post_inner_box">
               <div style="height:0px;width:0px;overflow:hidden;-webkit-margin-top-collapse: separate;"></div>            
               <h2 class="ttr_post_title">
                  <?php echo JHtml::link ($product->link.$ItemidStr, $product->product_name); ?>
               </h2>
               <div style="height:0px;width:0px;overflow:hidden;-webkit-margin-top-collapse: separate;"></div>
            </div>
      <?php echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$product,'currency'=>$currency)); ?>
      <?php echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product,'rowHeights'=>$rowsHeight[$row], 'position' => array('ontop', 'addtocart'))); ?>
      </div>
      </div>   
   </div>   
   </div>         
   </article>
   </div>    
   <?php 
   $columncounter++;
   $nb ++;
   if( $lg != 0 || $sm != 0 || $xs != 0)
   {
   if(($columncounter) % $lg == 0) 
   {?>
   <div style="clear: both;" class="visible-xs-block"></div>
   <div style="clear: both;" class="visible-md-block"></div>
   <?php
   }   
   elseif(($columncounter) % $sm == 0) 
   {?>
      <div style="clear: both;" class="visible-sm-block"></div>
   <?php
   }
   elseif(($columncounter) % $xs == 0)
   {?>
      <div style="clear: both;" class="visible-xs-block"></div>
   <?php
   }
   }
    if ($col == $products_per_row || $nb > $BrowseTotalProducts) { ?>
     <div class="clear"></div>
  </div>
    <?php
    $col = 1;
    $row++;
    } else {
    $col ++;
     }
   }
if(!empty($type)and count($products)>0){
    ?>
   <div class="clear"></div>
   </div>
    <?php
     }
   }
?>
Title: Re: Showing SKU in Products descriptions
Post by: GJC Web Design on February 20, 2020, 13:34:34 PM
               <h2 class="ttr_post_title">
                  <?php echo JHtml::link ($product->link.$ItemidStr, $product->product_name); ?>
               </h2>
<?php echo '<div class="skudiv">SKU: '.$product->product_sku.'</div>'; ?>
Title: Re: Showing SKU in Products descriptions
Post by: aseermrmr on February 20, 2020, 13:37:57 PM
sir
thank you so much for your help
it works great
thank you again
Title: Re: Showing SKU in Products descriptions
Post by: aseermrmr on February 20, 2020, 13:58:37 PM
one more sir please

in your code there is SKU word and i change it to part No

how i can do the same for the first code this one :
   <h1 itemprop="name" class="ttr_Prodes_Title"><?php echo $this->product->product_name ?></h1>
    <?php // Product Title END   ?>
   
</div>
<?php echo $this->product->product_sku ?>
Title: Re: Showing SKU in Products descriptions
Post by: GJC Web Design on February 20, 2020, 15:12:07 PM
<?php echo 'Part No: '.$this->product->product_sku; ?>
Title: Re: Showing SKU in Products descriptions
Post by: aseermrmr on February 20, 2020, 16:10:09 PM
thank you so much sir