VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: Agaton on July 30, 2019, 14:02:22 PM

Title: [SOLVED] Add to Cart - Alter Redirect
Post by: Agaton on July 30, 2019, 14:02:22 PM
Hi,

Can anyone help me with some guidance on how to alter the redirect when adding to cart. I don't want the ajax add to cart modal and I don't want it to redirect to the basket.

I just want the page to refresh with no redirect. Can someone guide me to the template I would need to alter please.

I am using Joomla 3.9.10 with vm 3.4.2.

I have searched VM forum and Google to no avail.

Thanks
Title: Re: Add to Cart - Alter Redirect
Post by: StefanSTS on July 30, 2019, 16:56:58 PM
Hi,

the easiest way might be to change the popup after adding a product.
You find padded.php in cart view.

Remove the buttons and give it a small timeout to disappear so the ajax can finish adding the product to cart.

Regards
Stefan
Title: Re: Add to Cart - Alter Redirect
Post by: PRO on July 30, 2019, 21:10:22 PM
Yea, best for usability to have the popup, but make it disappear
Title: Re: Add to Cart - Alter Redirect
Post by: Agaton on July 31, 2019, 09:17:29 AM
That's a very good idea.. never considered that. Thanks.
Title: Re: Add to Cart - Alter Redirect
Post by: AH on July 31, 2019, 09:42:49 AM
Here is the js change to make the popup disappear in vmprice.js


You can change the delay


Virtuemart.cartEffect = function(form) {

var dat = form.serialize();

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

    jQuery.ajax({
        type: "POST",
        cache: false,
        dataType: "json",
        timeout: "20000",
        url: Virtuemart.vmSiteurl + "index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS&format=json"+Virtuemart.vmLang+window.Itemid,
        data: dat
    }).done(

function(datas, textStatus) {

if(datas.stat ==1){
var txt = datas.msg;
} else if(datas.stat ==2){
var txt = datas.msg;
} else {
var txt = "<H4>"+vmCartError+"</H4>"+datas.msg;
}
if(usefancy){
jQuery.fancybox({
                "titlePosition" : "inside",
                "transitionIn" : "fade",
                "transitionOut" : "fade",
                "changeFade"    :   "fast",
                "type"          : "html",
                "autoCenter"    : true,
                "closeBtn"      : false,
                "closeClick"    : false,
                "content"       : txt,
                "autoDimensions": true,

                "onComplete"    : function () {
                    setTimeout(function () {
                        jQuery.fancybox.close();
                    }, 500); // 300 = 3 secs
                }
            });
} else {
jQuery.facebox( txt , 'my-groovy-style');
}

        jQuery('body').trigger('updateVirtueMartCartModule');
});

};
Title: Re: Add to Cart - Alter Redirect
Post by: Agaton on July 31, 2019, 13:28:12 PM
Thanks all for your ideas.

In the end I chose to alter the "continue-link" to refresh to the same page adding javascript to reload the page and maintain scroll position in the browser.

This way the client can add product, see it has been added, return to page and position on the page which in turn enhances the user experience.