Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Ошибка Division by zero in - Opencart 2.x


Recommended Posts

Помогите с ошибкой, в витрине магазина, на товаре со скидкой выдает ошибку: Notice Undefined index: special2 in /home/h001278042/h001278042.nichost.ru/docs/catalog/view/theme/tt_domino1/template/module/octabproductslider.tpl on line 46 Notice: Undefined index: price2 in /home/h001278042/h001278042.nichost.ru/docs/catalog/view/theme/tt_domino1/template/module/octabproductslider.tpl: Undefined index: price2 in 47 Warning: Division by zero in /home/h001278042/h001278042.nichost.ru/docs/catalog/view/theme/tt_domino1/template/module/octabproductslider.tpl on line 48

 

Вот часть кода, отвечающего за это

 

<?php if ((isset($product['is_new']) && $product['is_new']) || $productTab['id'] == "latest_product"):
                                        if($product['special']): ?>
                                            <div class="label-pro-sale">
                        <?php if($product['special']){
                          $a = ($product['special2']);
                          $b = ($product['price2']);
                          $c = round(($a-$b)/$b,2)*100;
                        }?> 
                        <?php if($product['special']){?>
                          <div class="sale-percent"><?php echo $c;?>%</div>
                        <?php }?>
                      </div>

Link to post
Share on other sites

<?php if($product['special']){
    $a = ($product['special2']);
    $b = ($product['price2']);
    $c = round(($a-$b)/$b,2)*100;
} ?> 

-->

<?php if($product['special']){
    $a = ($product['special2'] ? $product['special2'] : $product['special']);
    $b = ($product['price2'] ? $product['price2'] : $product['price']);
    $c = round(($a-$b)/$b,2)*100;
} ?>

p.s. *овнокод detected

Link to post
Share on other sites

30 минут назад, Baco сказал:
<?php if($product['special']){
    $a = ($product['special2']);
    $b = ($product['price2']);
    $c = round(($a-$b)/$b,2)*100;
} ?> 

-->

<?php if($product['special']){
    $a = ($product['special2'] ? $product['special2'] : $product['special']);
    $b = ($product['price2'] ? $product['price2'] : $product['price']);
    $c = round(($a-$b)/$b,2)*100;
} ?>

p.s. *овнокод detected

так и ваш код от нотисов не спасет. isset нужен

  • +1 1
Link to post
Share on other sites

36 минут назад, Baco сказал:
<?php if($product['special']){
    $a = ($product['special2']);
    $b = ($product['price2']);
    $c = round(($a-$b)/$b,2)*100;
} ?> 

-->

<?php if($product['special']){
    $a = ($product['special2'] ? $product['special2'] : $product['special']);
    $b = ($product['price2'] ? $product['price2'] : $product['price']);
    $c = round(($a-$b)/$b,2)*100;
} ?>

p.s. *овнокод detected

Не помогает

Link to post
Share on other sites

5 минут назад, Blast сказал:

так и ваш код от нотисов не спасет. isset нужен

А подробней можно?

 

Link to post
Share on other sites

30 минут назад, XRU13 сказал:

А подробней можно?

 

    $a = isset($product['special2']) ? $product['special2'] : $product['special'];
    $b = isset($product['price2']) ? $product['price2'] : $product['price'];

 

Link to post
Share on other sites

<?php if($product['special']){
    $a = !isset($product['special2']) ? $product['special'] : $product['special2'];
    $b = !isset($product['price2']) ? $product['price'] : $product['price2'];
    $c = round(($a-$b)/$b,2)*100;
} ?>

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.