News:

Looking for documentation? Take a look on our wiki

Main Menu

PROBLEM: Remove ajax fancybox in add to cart button (Buy Now button)

Started by VicHaunter, March 13, 2012, 20:03:35 PM

Previous topic - Next topic

VicHaunter

Hello,

I`m new in virtuemart 2 and have a little problem. In early versions you can disable ajax popup in add to cart button. I need to have a button that directly take me to the cart when i click but i have the problem that i cant disable ajax in administration.

Im trying to edit the file default_addtocart.php but it render the actions with ajax.

Then, ¿somebody knows how to remove the popup and load directly the cart when click in add to cart button?

Thankyou very much!!

I read some about in vm 1 you can create a button with onclick="submit()", but i test it and doesnt work.

DeepaVaith

oh! I'm having the same problem.  Does anyone have a solution to this as I'm new to VM .

Zegenrijk

This works for me to disable the ajax fancybox and go directly to the checkout screen after the click of a add to cart button (so far i know there is no possibility in the configuration of VM 2.0 to disable the ajax fancybox). I have tested it in IE9, FF11, Safari 5.1.4 (on windows), Chrome 17.0:

Find the file: /public_html/components/com_virtuemart/assets/js/vmprices.js

Under 'function sendtocart(form)' find and comment out these lines (by puting // in front of the row):
//   $.facebox({ text: datas.msg +"<H4>"+txt+"</H4>" }, 'my-groovy-style');
//   $.facebox({ text: datas.msg +"<H4>"+txt+"</H4>" }, 'my-groovy-style');
//   $.facebox({ text: "<H4>"+vmCartError+"</H4>"+datas.msg }, 'my-groovy-style');

Then find this code right under it (OLD)
if ($(".vmCartModule")[0]) {
$(".vmCartModule").productUpdate();
}

and put a new line after the last line (NEW) to redirect after the product update to the checkout page:
if ($(".vmCartModule")[0]) {
$(".vmCartModule").productUpdate();
window.location = "/vm/cart.html";
}

Note: in my case the url to the checkout screen is '/vm/cart.html'. If this is different to you, replace the url.

Of course it would be nicer to have a configuration possibility to disable in VM instead of hacking a files....

DeepaVaith

Hi! Thanks for your solution.  This works partially as the item is now added to the cart, but the redirection to
the cart view page does not happen if I don't give a javascript alert!!
Am I doing something wrong?

Thanks,
Deepa

mcflause

Here is what the code should look like:

Quotefunction(datas, textStatus) {
               if(datas.stat ==1){
                  //var value = form.find('.quantity-input').val() ;
                  var txt = form.find(".pname").val()+' '+vmCartText;
                                                $.facebox.settings.closeImage = closeImage;
                                                $.facebox.settings.loadingImage = loadingImage;
                                                $.facebox.settings.faceboxHtml = faceboxHtml;
                  //$.facebox({ text: datas.msg +"<H4>"+txt+"</H4>" }, 'my-groovy-style');
               } else if(datas.stat ==2){
                  var value = form.find('.quantity-input').val() ;
                  var txt = form.find(".pname").val();
                                                $.facebox.settings.closeImage = closeImage;
                                                $.facebox.settings.loadingImage = loadingImage;
                                                $.facebox.settings.faceboxHtml = faceboxHtml;
                  //$.facebox({ text: datas.msg +"<H4>"+txt+"</H4>" }, 'my-groovy-style');
               } else {
                                                $.facebox.settings.closeImage = closeImage;
                                                $.facebox.settings.loadingImage = loadingImage;
                                                $.facebox.settings.faceboxHtml = faceboxHtml;
                  //$.facebox({ text: "<H4>"+vmCartError+"</H4>"+datas.msg }, 'my-groovy-style');
               }
               if ($(".vmCartModule")[0]) {
                  Virtuemart.productUpdate($(".vmCartModule"));
               }
                                        window.location = "/component/virtuemart/cart"
            });

The previous poster lead me in the right direction, but the 'window-location' function had to moved out of the if statement.

This took me half a day to figure out... fml

rupesh

Quote from: mcflause on April 15, 2012, 22:38:58 PM
Here is what the code should look like:

Quotefunction(datas, textStatus) {
               if(datas.stat ==1){
                  //var value = form.find('.quantity-input').val() ;
                  var txt = form.find(".pname").val()+' '+vmCartText;
                                                $.facebox.settings.closeImage = closeImage;
                                                $.facebox.settings.loadingImage = loadingImage;
                                                $.facebox.settings.faceboxHtml = faceboxHtml;
                  //$.facebox({ text: datas.msg +"<H4>"+txt+"</H4>" }, 'my-groovy-style');
               } else if(datas.stat ==2){
                  var value = form.find('.quantity-input').val() ;
                  var txt = form.find(".pname").val();
                                                $.facebox.settings.closeImage = closeImage;
                                                $.facebox.settings.loadingImage = loadingImage;
                                                $.facebox.settings.faceboxHtml = faceboxHtml;
                  //$.facebox({ text: datas.msg +"<H4>"+txt+"</H4>" }, 'my-groovy-style');
               } else {
                                                $.facebox.settings.closeImage = closeImage;
                                                $.facebox.settings.loadingImage = loadingImage;
                                                $.facebox.settings.faceboxHtml = faceboxHtml;
                  //$.facebox({ text: "<H4>"+vmCartError+"</H4>"+datas.msg }, 'my-groovy-style');
               }
               if ($(".vmCartModule")[0]) {
                  Virtuemart.productUpdate($(".vmCartModule"));
               }
                                        window.location = "/component/virtuemart/cart"
            });

The previous poster lead me in the right direction, but the 'window-location' function had to moved out of the if statement.

This took me half a day to figure out... fml
is it "  window.location = "/component/virtuemart/cart"" this path is right?
becoz i'm getting error on this path even i tried
window.location = "index.php//component/virtuemart/cart" this also but its given error404

dorkus

my fancebox is not showing anymore after vm update from 2.0.4 to 2.0.6. it directly guides me to the checkout....

any idea where i can look to fix this?

please help :)