كيفية إخفاء طبقة التنقل حسب السعر وتصفية السعر لعدم تسجيل الدخول للمستخدم في الماجنتو 1.9؟
-
29-09-2020 - |
سؤال
هل من الممكن إخفاء Sort by Price
و Price Filter Navigation Layer
في صفحة قائمة منتجات الفئة للمستخدمين الذين لم يقوموا بتسجيل الدخول؟
المحلول 2
شكرًا لـ Claudiu Creanga على المساعدة، لقد قمت بتعديل الكود الخاص به ليعمل بشكل مثالي مع السمة الخاصة بي، وأنا أستخدم theme pure لـ icotheme.
- إخفاء الترتيب حسب السعر
استبدل هذا الرمز في 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>
مع :
<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>
- إخفاء طبقة التنقل لتصفية الأسعار
استبدل هذا الرمز في template\catalog\layer\view.phtml
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
مع:
<?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; ?>
نصائح أخرى
من المرجح أن يكون هذا الفلتر موجودًا template\catalog\product\list\toolbar.phtml
الكود الذي يهمك هو:
<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>
لذا احذف ذلك وأضف شيئًا مثل هذا:
<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>
* كود لم يتم اختباره
لا تنتمي إلى magento.stackexchange