News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Auto close add to cart pop up

Started by Kans, June 20, 2013, 12:55:31 PM

Previous topic - Next topic

Kans

Is there a way to automatically close the "add to cart" popup after a few seconds?

I tried editing the file facebox.js in /components/com_virtuemart/assets/js/
after the line
   $.facebox.loading()
add:
setTimeout($.facebox.close, 3000);

The problem with this solution is that it also auto closes the "Ask a question about this product" popup and the conditions popup in the check out, which is not good.

If not possible, how can I stay on the product page if I disable the popup?

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Kans

Hi, thanks for the suggestion but the problem remains.
Hiding it creates the same problem as auto-closing it. By hiding it I also hide the "ask a question about this product" and the "conditions". I only want to do changes to the add to cart popup.

If someone comes up with a solution, please share it! You would make my day:)

AH

If you are using the new fancybox and want the much loved "auto close"

Edit

components\com_virtuemart\assets\js\vmprices.js

At around line 75

replace

  if(usefancy){
                        $.fancybox({
                                "titlePosition" : "inside",
                                "transitionIn" : "elastic",
                                "transitionOut" : "elastic",
                                "type" : "html",
                                "autoCenter"    :   true,
                                "closeBtn"      :   false,
                                "closeClick"    :   false,
                                "content"       :   txt
                            }
                        );


with this

if(usefancy){
                        $.fancybox({
                                "titlePosition" : "inside",
                                "transitionIn" : "elastic",
                                "transitionOut" : "elastic",
                                "type" : "html",
                                "autoCenter"    :   true,
                                "closeBtn"      :   false,
                                "closeClick"    :   false,
                                "onComplete"    : function(){
                                    setTimeout( function() {$.fancybox.close(); },3500); // 3000 = 3 secs
                                },
                                "content"       :   txt
                            }
                        );


Adjust the timeout as required 3500 = 3.5 secs

This should not affect any other fancybox popups  8)
Regards
A

Joomla 3.10.11
php 8.0

beny.rfg

In the versions VM around 3.0.16 is code a little different (using jQuery):


if(usefancy){

  jQuery.fancybox({
"titlePosition" : "inside",
"transitionIn" : "fade",
"transitionOut" : "fade",
"changeFade"    :   "fast",
"type" : "html",
"autoCenter"    :   true,
"closeBtn"      :   false,
"closeClick"    :   false, 
                                        "onComplete"    : function(){
                                    setTimeout( function() {jQuery.fancybox.close(); },800);
                                },
"content"       :   txt

}

);

},

AH

This is the modified function for VM 3.0.17




Virtuemart.cartEffect = function(form) {

var dat = form.serialize();

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

    jQuery.ajax({
        type: "POST",
        cache: false,
        dataType: "json",
        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 +"<H4>"+form.find(".pname").val()+"</H4>";
} 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": false,
                "width"         : 400,
                "height"        : 'auto',
                "onComplete"    : function () {
                    setTimeout(function () {
                        jQuery.fancybox.close();
                    }, 1500); // 3000 = 3 secs
                }
            });
} else {
jQuery.facebox( txt , 'my-groovy-style');
}


Virtuemart.productUpdate();
});

}

Virtuemart.incrQuantity = (function(event) {
    var rParent = jQuery(this).parent().parent();
    quantity = rParent.find('input[name="quantity[]"]');
    virtuemart_product_id = rParent.find('input[name="virtuemart_product_id[]"]').val();
    Ste = parseInt(quantity.attr("step"));
    if (isNaN(Ste)) Ste = 1;
    Qtt = parseInt(quantity.val());
    if (!isNaN(Qtt)) {
        quantity.val(Qtt + Ste);
        maxQtt = parseInt(quantity.attr("max"));
        if(!isNaN(maxQtt) && quantity.val()>maxQtt){
            quantity.val(maxQtt);
        }
        Virtuemart.setproducttype(event.data.cart,virtuemart_product_id);
    }
});

Regards
A

Joomla 3.10.11
php 8.0