简体   繁体   English

Virtuemart 2-将产品图片添加到“添加到购物车”弹出窗口

[英]Virtuemart 2 - Add the product image to the “add to cart”-popup

I've been looking for this like everywhere now ;) 我一直在到处寻找它;)

I want to add the product image to the popup, but I can't figure out how to achieve this! 我想将产品图片添加到弹出窗口中,但是我不知道该如何实现! I've been searching for hours and hours now and next to that tried to code this myself but it won't work. 我一直在搜索数小时,然后尝试自己编写代码,但此方法无法正常工作。

So now I'm asking for help... if anyone has some ideas on this please let me know. 所以现在我要寻求帮助...如果有人对此有任何想法,请告诉我。 Afaik there's more people on the net that would like to see a "add to cart"-popup with some more informations given on it. Afaik网上有更多人希望看到“添加到购物车”弹出窗口,上面提供了更多信息。

Sincerly Thomas 真诚的托马斯

I just recently customised the add to cart popup on a site myself. 我最近刚刚在网站上自定义了“添加到购物车”弹出窗口。 The file you need to edit is components/com_virtuemart/controllers/cart.php (the function is called addJS if I remember correctly). 您需要编辑的文件是components / com_virtuemart / controllers / cart.php(如果我没记错的话,该函数称为addJS)。

You can find the API documentation for VirtueMart here: http://docs.virtuemart.net/api-vm2/ however I wrote my own plugin to fetch the VM data. 您可以在此处找到VirtueMart的API文档: http ://docs.virtuemart.net/api-vm2/,但是我编写了自己的插件来获取VM数据。 Then you can just use standard PHP rather than getting your head round the VM API. 然后,您可以只使用标准的PHP,而不必理会VM API。

If you decide to do it my way you can call custom classes from your plugin and output the image like so: 如果决定以我的方式进行操作,则可以从插件中调用自定义类并输出图像,如下所示:

$cart_image = plgMyCoolPlugin::_getImage($this->product->virtuemart_product_id);
echo '<img src='.$cart_image.'/>';

Remember you need to import your plugin type if you don't make it a system plugin: 请记住,如果您不将其设为系统插件,则需要导入您的插件类型:

JPluginHelper::importPlugin( 'mynewplugintype' );

Here's the function I use in my plugin: 这是我在插件中使用的功能:

    function _getImage($id)
    {       
        $db   =& JFactory::getDBO();    
        $sql  = "   SELECT
                            b.`file_url`
                    FROM
                            ".$db->nameQuote('#__virtuemart_product_medias')." AS a
                    INNER JOIN 
                            ".$db->nameQuote('#__virtuemart_medias')." AS b ON a.`virtuemart_media_id` = b.`virtuemart_media_id`  
                    WHERE
                            a.".$db->nameQuote('virtuemart_product_id')." = ".$id."
                    AND
                            b.".$db->nameQuote('file_mimetype')." = 'image/jpeg'
                    AND
                            b.".$db->nameQuote('file_type')." = 'product'
                    AND
                            b.".$db->nameQuote('file_is_forSale')." = '0'";

        $query = $db->setQuery($sql);
        $row  = $db->loadResultArray();
        if($db->getErrorNum()) {
            JError::raiseError( 500, $db->stderr());
        }
        if(empty($row)) $row[] = JURI::base().'images/defaultimage.jpg';
        return $row;
    }

Hope this helps :) 希望这可以帮助 :)

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

相关问题 在购物车中添加图片作为产品 - Add image in cart as product 禁用JOOMLA 1.7中的evinessmart组件的添加到购物车按钮上的弹出窗口 - Disable popup on add to cart button of virtuemart component in JOOMLA 1.7 以编程方式将产品添加到Virtuemart? - Programmatically add product to Virtuemart? Virtuemart 2-我怎样才能通过venuemart_product_id将商品添加到购物车会话中? - Virtuemart 2 - How i can add item into cart session with virtuemart_product_id? Virtuemart-添加到购物车,无价格 - Virtuemart - add to cart, without prices VirtueMart将文件(pdf)添加到产品 - VirtueMart add file(pdf) to product Virtuemart 2 / Joomla 2.5.4浏览页面上的Virtuemart添加到购物车按钮 - Virtuemart Add To Cart button on browse page for Virtuemart 2/Joomla 2.5.4 在美德玛特 3 的产品详细信息页面上的相关产品中添加数量和添加到购物车并以线性方式显示 - Adding qty and add-to-cart in related products on product detail page for virtuemart 3 and display in linear fashion Virtuemart 添加到购物车、价格详情等未出现 - Virtuemart add to cart, price details etc not appearing “添加到购物车”按钮无法正常工作功能众筹2-Joomla 2.5 - “Add to cart” button not working virtuemart 2 - joomla 2.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM