我使用aheadWorks的目录权限扩展来隐藏未登录客户的定价。但是,我也需要能够隐藏层定价。PHP代码是什么?我会把它放在什么文件中?
分层定价很好,但您不想向每个客户显示每个价格。要仅向登录访问者显示分级定价,请访问:app/design/frontend/default/default/template/catalog/product/view/tierprices.phtml
在这个文件上,添加这个PHP函数
<?php if(Mage::getSingleton('customer/session')->isLoggedIn()):
上述功能应在以下代码之前添加
<?php if (count($_tierPrices) > 0): ?>
然后在末尾添加此代码。
<?php endif; ?>
创建自己的布局文件,并在内部设置具有所需条件的模板文件。
<catalog_product_view>
<reference name="core_reference_name">
<action method="setTemplate">
<template>yournamespace/catalog/product/view.phtml</template>
</action>
</reference>
</catalog_product_view>
在类别列表页面、产品视图页面和比较弹出窗口中隐藏价格。按基本模块覆盖默认的Magento文件。
为基本模块Hideproductprice 创建文件夹和文件
app/etc/modules/Hideproductprice_Hideproductprice.xml
app/code/local/Hideproductprice/Hideproductprice/controllers/IndexController.php
app/code/local/Hideproductprice/Hideproductprice/etc/config.xml
app/code/local/Hideproductprice/Hideproductprice/Block/Index.php
app/design/frontend/base/default/layout/hideproductprice.xml
app/design/frontend/base/default/template/hideproductprice/price.phtml
1:添加以下代码您的自定义模块布局文件
(app/design/frontend/base/default/layout/hideproductprice.xml)
<default>
<reference name="catalog_product_price_template">
<action method="addPriceBlockType"><type>simple</type><block>catalog/product_price</block><template>hideproductprice/price.phtml</template></action>
<action method="addPriceBlockType"><type>grouped</type><block>catalog/product_price</block><template>hideproductprice/price.phtml</template></action>
<action method="addPriceBlockType"><type>configurable</type><block>catalog/product_price</block><template>hideproductprice/price.phtml</template></action>
<action method="addPriceBlockType"><type>virtual</type><block>catalog/product_price</block><template>hideproductprice/price.phtml</template></action>
<action method="addPriceBlockType"><type>bundled</type><block>catalog/product_price</block><template>hideproductprice/price.phtml</template></action>
</reference>
</default>
2:然后复制默认的"price.phtml"并将其放置在指定的位置(在我们的例子中为"hideproductprice/price.phtml")
<?php
if(!Mage::getSingleton('customer/session')->isLoggedIn()){
echo '<span class="login_for_price"><b>Login to See Price</b></span><br>';
return;
}
?>
Mage_Adminhtml_Block_Orders_Grid
/* adding customer name section */
$customerFirstNameAttr = Mage::getSingleton('customer/customer')->getResource()->getAttribute('firstname');
$collection->getSelect()
->joinLeft(
array('cusFirstnameTb' => $customerFirstNameAttr->getBackend()->getTable()),
'main_table.customer_id = cusFirstnameTb.entity_id AND cusFirstnameTb.attribute_id = '.$customerFirstNameAttr->getId(). ' AND cusFirstnameTb.entity_type_id = '.Mage::getSingleton('customer/customer')->getResource()->getTypeId(),
array('customer_name' =>'cusFirstnameTb.value')
);
/* end adding customer name section */