News:

Support the VirtueMart project and become a member

Main Menu

[FIX] Use VirtueMart CSS + Bootstrap layouts

Started by iWim, August 27, 2025, 16:10:19 PM

Previous topic - Next topic

iWim

I may have found a solution for a bug in VM where the setting for Use the VirtueMart CSS is ignored when selecting any Bootstrap version.

The solution is a small change to a core file. It would be great if someone can check it and than it could be added to core for the next update.

BEFORE THE FIX
1. Go to VirtueMart Configuration > tab Templates
2. Go to section Templates & Layouts
3. At Layout Bootstrap version select None (Use Legacy)

4. Go to section Core Css Styles & Javascripts (only for experts)
5. Set Use the VirtueMart CSS to Yes or No

Check the frontend code:
/components/com_virtuemart/assets/css/vm-ltr-common.css is loaded or not depending on setting Use the VirtueMart CSS to Yes or No.

6. Go back to #3 and select a Bootstrap version

Re-check the frontend code:
The setting for Use the VirtueMart CSS is ignored and
/components/com_virtuemart/assets/css/vm-bs#-common.css is always loaded.

THE FIX
Open the file ~/administrator/components/com_virtuemart/helpers/vmjsapi.php
(Note: this is a core file!)

At line 897 you'll findif (!VmConfig::get('css', TRUE)) {
  return FALSE;
}
Move these 3 lines up after if ($cssFile) return; on line 879(...)
static $cssSite;
if ($cssSite) return;

  if (!VmConfig::get('css', TRUE)) {
    return FALSE;
  }

  // we load one common css and put styles in there
  (...)

AFTER THE FIX
At Layout Bootstrap version select any option
Set Use the VirtueMart CSS to Yes or No

Re-check the frontend code:
The CSS from any layout is loaded or not depending on the Use the VirtueMart CSS setting.

B/C BREAK
Because before this fix the setting for Use the VirtueMart CSS was ignored, webshops using a Bootstrap layout and have Use the VirtueMart CSS set to No will loose styling after the update.

They will have to set Use the VirtueMart CSS to Yes.