VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: WebStuff on July 15, 2013, 18:26:29 PM

Title: Disable Add to Cart when Javascript is disabled.
Post by: WebStuff on July 15, 2013, 18:26:29 PM
VM 2.0.20b
J2.5.11
PHP 5.4.6
Searched for this and whilst I've found loads of threads on disabling add to cart via templates for products and categories I have not found a solution to my problem.
I need to stop the add to cart button having any functionality if javascript is disabled but display it if javascript is enabled in the users browser.
I've tried removing the button from the template then only displaying it via javascript, therefore they need javascript enabled to see the button, but this stops the add to cart working at all as I assume jQuery can't find the button or form.

I need to only allow add to cart if javascript is enabled.

Any help greatly appreciated.
Title: Re: Disable Add to Cart when Javascript is disabled.
Post by: Maxim Pishnyak on July 15, 2013, 21:47:17 PM
Showing not usable addtocart button could show customers that they can't use web page(s).

If you'll hide button for those who has using js turned off, these people wouldn't have an idea that it's possible to buy a thing at your "web shop".
Title: Re: Disable Add to Cart when Javascript is disabled.
Post by: WebStuff on July 16, 2013, 12:37:54 PM
Quote from: Maxim Pishnyak on July 15, 2013, 21:47:17 PM
If you'll hide button for those who has using js turned off, these people wouldn't have an idea that it's possible to buy a thing at your "web shop".
Thanks for the reply.
I have a message that explains that they need to have Javascript and Cookies enabled in order to purchase items. On VM1 it was easy to disable the add to cart until JS was enabled but if I use the same approach on VM2 the jQuery doesn't work.
Title: Re: Disable Add to Cart when Javascript is disabled.
Post by: Maxim Pishnyak on July 16, 2013, 12:51:10 PM
Quote from: mirrorsandglass on July 16, 2013, 12:37:54 PM
I have a message that explains that they need to have Javascript and Cookies enabled in order to purchase items.
Still not functional button and displaying your message at one time on current page could do the right job.

I wish VM Team to work on more important stuff.
Title: Re: Disable Add to Cart when Javascript is disabled.
Post by: WebStuff on July 17, 2013, 11:28:33 AM
Quote from: Maxim Pishnyak on July 16, 2013, 12:51:10 PM
I wish VM Team to work on more important stuff.
Me too. :-)
It was just if someone knew how to do it. I'll keep digging.
Title: Re: Disable Add to Cart when Javascript is disabled.
Post by: jenkinhill on July 17, 2013, 12:40:09 PM
Not in VM, but I have used this code snippet before. It does not disable things but redirects to an advice page (eg. about how to turn JS on)

<NOSCRIPT>
Java Script is disabled in your browser!
<meta http-equiv="refresh" content="0;url=(redirectedpage)">
</NOSCRIPT>
Title: Re: Disable Add to Cart when Javascript is disabled.
Post by: WebStuff on July 17, 2013, 17:12:35 PM
Thanks Jenkinhill I hadn't thought of redirecting them to a different page.
That will do nicely for now.  :D