Author Topic: Undefined variable: percentage in line 166  (Read 307 times)

ibnati

  • Beginner
  • *
  • Posts: 28
  • A beginner
Undefined variable: percentage in line 166
« on: July 13, 2018, 18:06:11 pm »
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

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27105
  • Always on vacation
    • Jenkin Hill Internet
Re: Undefined variable: percentage in line 166
« Reply #1 on: July 13, 2018, 18:13:49 pm »
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

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM 3.4.3.9989 on Joomla 3.9.1 PHP 7.0.32
Testing VM 3.4.3.9993 on Joomla 3.9.1

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3530
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Undefined variable: percentage in line 166
« Reply #2 on: July 13, 2018, 18:56:08 pm »
move
Code: [Select]
$percentage = "";before
Code: [Select]
if ($isSaleLabel) {

ibnati

  • Beginner
  • *
  • Posts: 28
  • A beginner
Re: Undefined variable: percentage in line 166
« Reply #3 on: July 13, 2018, 19:36:47 pm »
thank you very much , the issue is fixed now