A
A
Alexander Sinelnikov2019-08-26 19:35:33
opencart
Alexander Sinelnikov, 2019-08-26 19:35:33

How to hide the div block of the "Bookmarks" "Comparison" counter if the value is zero?

Hello everyone, please tell me how can I hide the div block of the counter Wish list, comparison if the value is zero? 5d6409f236b4c499935567.png
here is the code

<?php if ($rev_lang || $rev_curr || $rev_srav || $rev_wish || $rev_acc) { ?>
                    <div class="top-links verh nav pull-right <?php if ((count($informations) + count($revtheme_header_links)) > 4) { ?>text_ico_skrit<?php } ?>">
<ul class="list-inline">
                            
                            <?php if ($rev_lang) { ?>
                            <?php echo $language; ?>
                            <?php } ?>
                            <?php if ($rev_curr) { ?>
                            <?php echo $currency; ?>
                            <?php } ?>
                            <?php if ($rev_srav) { ?>
                            <li>
                                <a href="<?php echo $compare; ?>" class="dropdown-toggle"><span id="compare-total"><?php echo $text_compare; ?></span></a>
                            </li>
                            <?php } ?>
                            <?php if ($rev_wish) { ?>
                            <li>
                                <a href="<?php echo $wishlist; ?>" class="dropdown-toggle"><span id="wishlist-total"><?php echo $text_wishlist; ?></span></a>
                            </li>
                            <?php } ?>

                            <?php if ($rev_acc) { ?>
                            <li class="dropdown"><a href="<?php echo $account; ?>" title="<?php echo $text_revlogged; ?>" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> <span class="hidden-xs hidden-sm"><?php echo $text_revlogged; ?></span><i class="fa fa-chevron-down strdown"></i></a>
                                <ul class="dropdown-menu dropdown-menu-right">
                                    <?php if ($logged) { ?>
                                    <li><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a></li>
                                    <?php if (isset($setting_all_settings['revaccount_orders']) && $setting_all_settings['revaccount_orders']) { ?>
                                    <li><a href="<?php echo $order; ?>"><?php echo $text_rev_text_order; ?></a></li>
                                    <?php } ?>
                                    <?php if (isset($setting_all_settings['revaccount_files']) && $setting_all_settings['revaccount_files']) { ?>
                                    <li><a href="<?php echo $download; ?>"><?php echo $text_rev_text_download; ?></a></li>
                                    <?php } ?>
                                    <li><a href="<?php echo $logout; ?>"><?php echo $text_logout; ?></a></li>
                                    <?php } else { ?>
                                    <?php if ($popup_login) { ?>
                                    <li><a onclick="get_revpopup_login();"><?php echo $text_login; ?></a></li>
                                    <?php } else { ?>
                                    <li><a href="<?php echo $login; ?>"><?php echo $text_login; ?></a></li>
                                    <?php } ?>
                                    <li><a href="<?php echo $register; ?>"><?php echo $text_register; ?></a></li>
                                    <?php } ?>
                                </ul>
                            </li>
                            <?php } ?>
                        </ul>
                    </div>
                    <?php } ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zoozag, 2019-08-26
@zoozag

Are $text_compare and $text_wishlist just numbers?
Then:

<?php if ($rev_srav) { ?>
<li <?php echo $text_compare ? '' : 'class="hidden"';?>>
    <a href="<?php echo $compare; ?>" class="dropdown-toggle"><span id="compare-total"><?php echo $text_compare; ?></span></a>
</li>
<?php } ?>
<?php if ($rev_wish) { ?>
<li <?php echo $text_wishlist ? '' : 'class="hidden"';?>>
    <a href="<?php echo $wishlist; ?>" class="dropdown-toggle"><span id="wishlist-total"><?php echo $text_wishlist; ?></span></a>
</li>
<?php } ?>

And do not forget to check the number of products and add / remove the
UPD class when adding / removing from favorites. In your case, $text_compare and $text_wishlist contain all the markup, so they will always pass the condition.
In the controller, add the $compare_count and $wishlist_count variables, which contain just the numeric values ​​of the compare and favorite counters. And add any class for , for example class="wishlist0".
Then at the style level you can hide:
.wishlist0 sup {
  display: none;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question