Jump to content

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>

Share this post


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

Share this post


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

Share this post


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

Не помогает

Share this post


Link to post
Share on other sites
5 минут назад, Blast сказал:

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

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

 

Share this post


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'];

 

Share this post


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;
} ?>

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×

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.