Invalid Token, in view=cart task=updatecart
It happened that we missed to check the token storing the cart data. So we added the check now, but some older layouts miss the token in the formdata. So how to fix that?
- The "easiest" way is to disable the overrides in the vm config. But this changes all layouts to the default layout of VirtueMart.
- Find the used overrides in your template and disable just the cart overrides.
- Find your used override file of your template and fix it adding one line to the form. Just somewhere between the <form> tags. We can edit the files within Joomla, so this option is maybe even easier then option 2 (it would need FTP).
- Just download this plugin, install, publish and done. Download plugin Tokencart.
1. The easy way
Just go the VirtueMart Config, => tab Templates, scroll down to the section =>Core Css Styles & Javascripts and disable "Use current shop template overrides"
2. and 3. Find your files
Now we need to find first, which template is used, and in special, which child of the template. Usually a template is set in the template manager, so we must go there and check the default template to know exactly which template is in use. Of course, template can be also set by the menu item and by VirtueMart, or even vm category. So if the manual below does not work for you, check back if you are in the right template. Use our forum or discord to get help.
So if you know the used template, then the files is to find usually here.
templates/{yourTemplateName}/html/com_virtuemart/cart
So if you just rename this folder, you would use the default core layouts just for the cart and keep your design for the rest of the shop. So if you absolutly want to avoid to touch a file with code, then you can stop here. But I encourage you to go further, the fix is really easy.
3. Just Fix the file
In general, just one line need to be added.
<input type="hidden" name="<?php echo vRequest::getFormToken(); ?>" value="1" />
But the real problem is to find the used file. The file is usually to find here
templates/{yourTemplateName}/html/com_virtuemart/cart/default.php
So we open our used template in Joomla, just not "styles", but "template". There we can see the files, for example if we would click on "VM Basic Details and Files", then we see the files of this template and can edit them.
So just browse in the trunk /templates/yourtemplate to html, just click on it. Click on com_virtuemart, then cart. Open the file default.php just by clicking on it.
So just need to search for this
<input type='hidden' name='task' value='updatecart'/>
<input type='hidden' name='option' value='com_virtuemart'/>
<input type='hidden' name='view' value='cart'/>
Add there the line above, so that it looks like this
<input type='hidden' name='task' value='updatecart'/>
<input type='hidden' name='option' value='com_virtuemart'/>
<input type='hidden' name='view' value='cart'/>
<input type="hidden" name="<?php echo vRequest::getFormToken(); ?>" value="1" />
Store it. Done. Test it!
Troubleshooting
But VirtueMart has a multiple Bootstrap layout system. So it runs with custom files or bootstrap files. Similiar to the first chapter, just go the VirtueMart Config, => tab Templates, scroll down to the section =>Template and Layouts and check the dropdown value for "Layout Bootstrap version". If your value is not "None", then just translate for example "Bootstrap 5" to bs5. And that just means, that we do not look for the default.php, but bs5-default.php.
If you are uncertain, enable the vmdebug just for admins, login add something to the cart and check the debug output. After "vmdebug FE main controller with controller cart and task" you see stuff like
So in my case, I know that the bs5-default.php is used.
It is very rare that this problem may arise. The main reason is, that old overrides are still the first to use. So there was no reason for templaters to write their overrides with bsX as default. But some very modern templates may use this new feature and so I added it to the tutorial.
And there are some templates which developed an own technic to allow overrides of their templates. Before joomla introduced the child templates, a template used already an override of the default layouts (which lay in the component folder, not in the template folder). So some templates developed a special technic to allow an override on the override. A sign for that is that all overriden files in a directory have the same size.
In this case you may checkout for example this folder. This is just an example for older VirtuePlanet templates before Joomla supported child templates.
templates/{yourTemplateName}/layouts/default/html/com_virtuemart
I hope this makes it easy to fix your installation. If there are still problems, just write in our forum or discord.
