Comment masquer la COUCHE DE NAVIGATION SORT BY PRICE et PRICE FILTER pour un utilisateur non connecté dans magento 1.9 ?

magento.stackexchange https://magento.stackexchange.com/questions/108673

  •  29-09-2020
  •  | 
  •  

Question

Est-il possible de masquer le Sort by Price et Price Filter Navigation Layer sur la page de liste des produits de la catégorie pour les utilisateurs qui ne sont pas connectés ?

Était-ce utile?

La solution 2

Merci à Claudiu Creanga pour son aide, j'ai modifié son code pour qu'il fonctionne parfaitement avec mon thème, j'utilise le thème puro pour l'icotheme.

  1. masquer le tri par prix

Remplacez ce code dans template\catalog\product\list oolbar.phtml

                                            <ul id="sort_by" class="sort_by collapse">
                                            <?php foreach ($this->getAvailableOrders() as $_key => $_order): ?>
                                                <li>
                                                    <a href="<?php echo $this->getOrderUrl($_key, 'asc') ?>"><?php echo $this->__($_order) ?></a>
                                                </li>
                                            <?php endforeach; ?>
                                        </ul>

avec :

                                            <ul id="sort_by" class="sort_by collapse">
                                        <?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
                                            <?php if(!Mage::getSingleton('customer/session')->isLoggedIn()): //not logged in, hide price ?>
                                                <?php if(strpos($this->__($_order), "Price") === false):  ?>
                                                <li>
                                                    <a href="<?php echo $this->getOrderUrl($_key, 'asc') ?>"><?php echo $this->__($_order) ?></a>
                                                </li>
                                                <?php endif; ?>
                                            <?php else: // logged in ?>
                                                <li>
                                                    <a href="<?php echo $this->getOrderUrl($_key, 'asc') ?>"><?php echo $this->__($_order) ?></a>
                                                </li>

                                            <?php endif; ?>
                                        <?php endforeach; ?>
                                        </ul>
  1. Masquer la couche de navigation du filtre de prix

Remplacez ce code dans template\catalog\layer\view.phtml

                    <dt><?php echo $this->__($_filter->getName()) ?></dt>
                <dd><?php echo $_filter->getHtml() ?></dd>

avec:

                <?php if(!Mage::getSingleton('customer/session')->isLoggedIn()): //not logged in, hide price ?>
                <?php if(strpos($this->__($_filter->getName()), "Price") === false):  ?>
                    <dt><?php echo $this->__($_filter->getName()) ?></dt>
                    <dd><?php echo $_filter->getHtml() ?></dd>
                <?php endif; ?>
            <?php else: // logged in ?>
                <dt><?php echo $this->__($_filter->getName()) ?></dt>
                <dd><?php echo $_filter->getHtml() ?></dd>
            <?php endif; ?>

Autres conseils

Ce filtre est probablement dans template\catalog\product\list\toolbar.phtml

Le code qui vous intéresse est :

 <select onchange="setLocation(this.value)" title="<?php echo $this->__('Sort By') ?>">
                    <?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
                        <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
                            <?php echo $this->__($_order) ?>
                        </option>
                    <?php endforeach; ?>
                </select>

alors supprimez-le et ajoutez quelque chose comme ceci :

<select onchange="setLocation(this.value)" title="<?php echo $this->__('Sort By') ?>">
    <?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
        <?php 
            if(!Mage::getSingleton('customer/session')->isLoggedIn()): //not logged in, hide price ?>

                <?php if(strpos($this->__($_order), "Price") === false):  ?>
                    <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
                        <?php echo $this->__($_order) ?>
                    </option>
                <?php else: // logged in ?>

                    <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
                        <?php echo $this->__($_order) ?>
                    </option>
               <?php endif; ?>
           <?php endif; ?>

    <?php endforeach; ?>
</select>

*code non testé

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top