VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: ibnati on June 13, 2018, 02:13:40 AM

Title: update error on the cart module
Post by: ibnati on June 13, 2018, 02:13:40 AM
hello

i have used   virtuemart for the shop area of the site

but i remarked asmall error on the vrtuemart cart also it doesn't update numbers of product and don't remove products  from the cart when i click on remove iconswhen the header is sticky and when the header  menu is not sticky it works correctly , can you please can you check it and tell me how to fix it ?

the site link is http://devo.cutwatches.com/index.php/en/grid-products 

and i use the php 7.0 and latest version of virtuemart   , let me know if you need more infos

thanks
amine

Title: Re: update error on the cart module
Post by: jenkinhill on June 13, 2018, 09:48:19 AM
Quote from: ibnati on June 13, 2018, 02:13:40 AM
it doesn't update numbers of product and don't remove products  from the cart when i click on remove iconswhen the header is sticky and when the header  menu is not sticky it works correctly

So the error is on;py seen when the tamplate header is fixed. The issue is therefore with your template, not with VirtueMart, presumably a JavaScrip conflict.
Title: Re: update error on the cart module
Post by: GJC Web Design on June 13, 2018, 10:51:18 AM
Yes .. template issue ... the sticky header is a completely different duplicated html  -- i.e. there is 2 of everything on the page and I assume having 2 cart modules isn't working
Title: Re: update error on the cart module
Post by: ibnati on June 14, 2018, 01:44:55 AM
also the issue is not on the header it on the update script of the module because when i use an other module it works but the issue is that the other module don't have remove from cart option

also this the update js of this module may be you can see where is the issue :

}

// Remove item in cart
$(function(){
    var cprefix = "#vmCartModule", wcart = $(cprefix),
    releaseCart = function(rs){
        var ncart = $(rs.data).filter(cprefix);
        if(!ncart.length) {
            return false;
        }
        wcart.find('.moduleMiniCart').html(ncart.find('.moduleMiniCart').html());
        wcart.find('.view_cart_link').html(ncart.find('.view_cart_link').html());
    };

    wcart.on({
        'fetch-cart': function(){
            var $this = $(this);

            $.ajaxSetup({ cache: false });
            var params = {
                option: 'com_ajax',
                module: 'virtuemart_carte',
                method: 'getData',
                format: 'json'
            };
            $.getJSON(buildUrl(location.href), params,function (rs, textStatus) {
                releaseCart(rs);                               
            });
        }
    });

    // remove item in cart
    $(document).delegate('[data-miniaction="rcart"]', 'submit.removeItem', function(){

        wcart.addClass('process');           
        $.post(buildUrl(location.href), $(this).serialize(), function(rs){ 
            releaseCart(rs);
        }).done(function(){
            wcart.removeClass('process');
        });

        return false;     
    });

    // ajax add
    window.Virtuemart = $.extend(window.Virtuemart, {
        cartEffect: function (form) {

            if(usefancy){ $.fancybox.showActivity(); }

            $.ajax({
                type: "POST",
                cache: false,
                dataType: "json",
                url: window.vmSiteurl + "index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS&format=json"+vmLang,
                data: form.serialize(),
                beforeSend: function(){
                    wcart.addClass('process');
                },
                complete: function(){
                    wcart.removeClass('process');
                }
            }).done(function(datas, textStatus) {

                if(datas.stat ==1){

                    var txt = datas.msg;
                } else if(datas.stat ==2){
                    var txt = datas.msg +"<H4>"+form.find(".pname").val()+"</H4>";
                } else {
                    var txt = "<H4>"+vmCartError+"</H4>"+datas.msg;
                }       
                if(usefancy){
                    $.fancybox({
                        "titlePosition" :     "inside",
                        "transitionIn"    :    "fade",
                        "transitionOut"    :    "fade",
                        "changeFade"    :   "fast",
                        "type"            :    "html",
                        "autoCenter"    :   true,
                        "closeBtn"      :   false,
                        "closeClick"    :   false,
                        "content"       :   txt
                    });
                } else {
                    $.facebox.settings.closeImage = closeImage;
                    $.facebox.settings.loadingImage = loadingImage;
                    $.facebox({ text: txt }, 'my-groovy-style');
                }

                // update cart
                wcart.trigger('fetch-cart');
            });
        }     
    });
});

})(jQuery);