如何显示wishlist标题菜单中的产品数量?这就是我想看起来像this:
我试过这样的事情:
<a href="/index.php?fc=module&module=blockwishlist&controller=mywishlist"
title="{l s='My wishlists' mod='blockwishlist'}"
rel="nofollow">{l s='Wishlist' mod='blockwishlist'} ({'wishlist'|count})
</a>
但它似乎计算我的愿望清单,而不是我的愿望清单中的产品。
这是这个问题的快速解决方案。这不是100%有效,但它会做到这一点。
$current_user = (int)$this->context->cookie->id_customer;
$id_wishlist = Db::getInstance()->getValue("SELECT id_wishlist FROM `"._DB_PREFIX_."wishlist` WHERE id_customer = '$current_user'");
$count_products = Db::getInstance()->getValue("SELECT COUNT(id_wishlist_product) FROM `"._DB_PREFIX_."wishlist_product` WHERE id_wishlist = '$id_wishlist'");
$this->smarty->assign(array(
'current_user' => $count_products,
'cart' => $this->context->cart,
'cart_qties' => $this->context->cart->nbProducts(),
'logged' => $this->context->customer->isLogged(),
'customerName' => ($this->context->customer->logged ? $this->context->customer->firstname.' '.$this->context->customer->lastname : false),
'firstName' => ($this->context->customer->logged ? $this->context->customer->firstname : false),
'lastName' => ($this->context->customer->logged ? $this->context->customer->lastname : false),
'order_process' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order'
));
return $this->display(__FILE__, 'blockuserinfo.tpl');
}*注意:如果用户有多个愿望清单,则该技巧仅适用于愿望清单
它运行正常,但在“blockuserinfo.tpl”中变量不是$ count_products,您必须使用$ current_user。所以,要添加的好线是:
{l s='Wishlist' mod='blockwishlist'} ({$current_user})