简体   繁体   English

在Magento中为客人显示某些产品的自定义添加到购物车模板

[英]Show Custom Add To Cart Template on Certain Products for Guest in Magento

I want to force users to be register on order page to add certain products in the cart. 我想强迫用户在订单页面上注册,以在购物车中添加某些产品。 I've a custom Add to Cart phtml. 我有一个自定义的Add to Cart phtml。 To activate this special add to cart for certain products I use the following code in products as follows 为了激活某些产品的特殊add to cart ,我在产品中使用以下代码,如下所示

<reference name="product.info.addtocart">
  <action method="setTemplate">   
    <template>catalog/product/view/customtemplate.phtml</template>
  </action>
</reference>

Can anybody give me directions in how to force users to be logged for order those certain products to use this template ie only logged in users can use my custom template? 有人可以指导我如何强制用户登录以订购某些产品使用此模板,即只有登录的用户才能使用我的自定义模板吗?

in the template file catalog/product/view/customtemplate.phtml , you can check if the customer is logged-in 在模板文件catalog/product/view/customtemplate.phtml ,您可以检查客户是否已登录

if(Mage::getSingleton('customer/session')->isLoggedIn())
{
    // display the contents of the template file
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM