News:

Support the VirtueMart project and become a member

Main Menu

[SOLVED] Add to Cart - Alter Redirect

Started by Agaton, July 30, 2019, 14:02:22 PM

Previous topic - Next topic

Agaton

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

StefanSTS

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
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

PRO

Yea, best for usability to have the popup, but make it disappear

Agaton

That's a very good idea.. never considered that. Thanks.

AH

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');
});

};
Regards
A

Joomla 3.10.11
php 8.0

Agaton

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.