Joomla插件在登录时无法正常工作,如何解决?

时间:2019-02-20 15:39:24

标签: joomla

在我的Joomla / Virtuemart中,我遇到了问题,登录后愿望清单无法使用。

这是代码

    public static function addWishlistButton($product)
{
    if (self::getZtvirtuemarterSetting()->enable_wishlist == '1'):
        if (!class_exists('ZtvirtuemarterModelWishlist')) require(JPATH_SITE . '/components/com_ztvirtuemarter/models/wishlist.php');
        $mainframe = JFactory::getApplication();
        $wishlistIds = $mainframe->getUserState("com_ztvirtuemarter.site.wishlistIds", array());
        ?>

        <div class="wishlist list_wishlists<?php echo $product->virtuemart_product_id; ?>">
            <?php
            $user = JFactory::getUser();

            if ($user->guest) :
            ?>
                <a class="add_to_wishlist <?php echo in_array($product->virtuemart_product_id, $wishlistIds) ? 'go_to_whishlist active' : ''; ?>"
                   onclick="ZtVirtuemarter.wishlist.add('<?php echo $product->virtuemart_product_id; ?>');">
                    <i class="fa fa-heart-o"></i>
                    <span><?php echo JText::_("ADD_TO_WHISHLIST"); ?></span>
                </a>
            <?php
            else :
                JPluginHelper::importPlugin('System');
                $dispatcher = JDispatcher::getInstance();
                $results = $dispatcher->trigger('onBeforeRender');

                if ($results[0] == 'true') {
                    $wishlistModel = new ZtvirtuemarterModelWishlist();
                    $allproducts = $wishlistModel->getProducts();
                    foreach ($allproducts as $productbd) {
                        $allprod['id'][] = $productbd['virtuemart_product_id'];
                    }
                }
                ?>
                <a class="add_to_wishlist <?php echo in_array($product->virtuemart_product_id, $allprod['id']) ? 'go_to_whishlist active' : ''; ?>"
                   onclick="ZtVirtuemarter.wishlist.add('<?php echo $product->virtuemart_product_id; ?>');">
                    <i class="fa fa-heart-o"></i>
                    <span><?php echo JText::_("ADD_TO_WHISHLIST"); ?></span>
                </a>
            <?php endif; ?>
        </div>
    <?php endif;
}

插件为plugins / system / ztvirtuemarter / ztvirtuemarter.php

有什么办法可以解决?代码中要更改的内容?

Joomla版本是3.9.3

谢谢

0 个答案:

没有答案