News:

Looking for documentation? Take a look on our wiki

Main Menu

Undefined variable: percentage in line 166

Started by ibnati, July 13, 2018, 18:06:11 PM

Previous topic - Next topic

ibnati

hello

i see a warning "Undefined variable: percentage in line  166" on the product page of Vm also the template use this cod to show Percentage             

<?php if(($isSaleLabel != 0) && $vm_labels_sales) : ?>
                     <div class="label-pro status-sale"><span><?php echo $percentage; ?></span></div>  //line 166
                  <?php endif; ?>


and this is the daclaration of the Percentage
   // Percentage
         if ($isSaleLabel) {
            $dtaxs = array();
            if($product->prices["DATax"]) $dtaxs = $product->prices["DATax"];
            if($product->prices["DBTax"]) $dtaxs = $product->prices["DBTax"];            
            foreach($dtaxs as $dtax){
               if(!empty($dtax)) {
                  $discount = rtrim(rtrim($dtax[1],'0'),'.');
                  $operation = $dtax[2];
                  $percentage = "";               
                  switch($operation) {
                     case '-':
                        $percentage = "-".$discount;
                        break;
                     case '+':
                        $percentage = "+".$discount;
                        break;
                     case '-%':
                        $percentage = "-".$discount."%";
                        break;
                     case '+%':
                        $percentage = "+".$discount."%";
                        break;
                     default:
                        return true;   
                  }
               }               
            }
         }
         // End Percentage


how can i fix this please ?

thanks
amine

jenkinhill

In default VM3.2.15 $percentage is only used in the Paypal plugin ( paypalstd.php ).  So I guess the issue is with your template or overrides.
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

Studio 42

move
$percentage = "";
before
if ($isSaleLabel) {

ibnati

thank you very much , the issue is fixed now