Come nascondere Ordina per prezzo e prezzi Strato di navigazione del filtro per non accesso utente in Magento 1.9?
-
29-09-2020 - |
Domanda
È possibile nascondere il Sort by Price
e Price Filter Navigation Layer
nella categoria Pagina dell'elenco prodotti per gli utenti che non sono registrati?
Soluzione 2
Grazie per Claudiu Creanga per chiedere aiuto, ho modificato il suo codice per lavorare perfettamente con il mio tema, io uso tema Puro per Iccotome.
- .
- nascondi il tipo per prezzo
- Nascondi il livello di navigazione del filtro dei prezzi
Sostituisci questo codice in Template \ Catalog \ Prodotto \ List \ Toolbar.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>
.
Con:
<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>
.
Sostituisci questo codice in Template \ Catalog \ Layer \ view.phtml
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
.
Con:
<?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; ?>
.Altri suggerimenti
Il filtro è più probabile in template\catalog\product\list\toolbar.phtml
Il codice che è di interesse per te è:
<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>
.
quindi cancellalo e aggiungi qualcosa del genere:
<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>
.
* Codice non testato
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange