After migration to joomla 4/5 /com_virtuemart/sublayouts/snippets.php on line 30

Started by Olive, April 13, 2025, 06:20:07 AM

Previous topic - Next topic

Olive

After migration to joomla 4/5 from 3.12 get this line on productpages;

Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in
/templates/shaper_helixultimate/html/com_virtuemart/sublayouts/snippets.php on line 30

VirtueMart 4.4.4 11101
Joomla 5


iWim

That may not be a VirtueMart issue.
What is your php version?

The warning comes from an override file in your template.

Compare your override file and the original file and apply the changes.
Override: ~/templates/shaper_helixultimate/html/com_virtuemart/sublayouts/snippets.php
Original: ~/components/com_virtuemart/sublayouts/snippets.php

Also I recommend updating to VirtueMart 4.4.6.

Olive

Thank you for your answer.

PHP 8.1.32

Where i have to add the override?

Should 4.4.6 solve the problem?



iWim

By that answer I'll asume you did not create that override...

Updating to the latest version(s) may not solve this issue.
But being on the latest version may exclude potential bugs that may have been fixed in never versions.
(4.4.4 has a bug with saving images)


Did the override come with the template?
Did you have someone create it?
Did you update the template when you updated from J3 to J4/5?

Some Joomla 3 templates may not work correctly on Joomla 4/5 or on higher PHP versions.

I don't know what snippets.php does or why you have an override, but...
You can temporary rename the file and see what happens.

You can do that with FTP, your hosts file manager or through Joomla.
Through Joomla:
- Go to System > Site Templates > Shaper_helixultimate Details and Files
- Look in the tree for html/com_virtuemart/sublayouts/snippets.php
- Click on snippets.php to open it and then click on the button Rename File
- Rename it to i.e. 0snippets.php

Check the product pages and see what happened.
The warning may be gone, but what else changed?

Olive

Thank you Wim,

i renamed the snippets.php in
templates/shaper_helixultimate/html/com_virtuemart/sublayouts


The warning has gone indeed, also the Yotpo product reviews.
For the rest everything seems to work.

The template is helix ultimate 2.1.2
VM uses joomla default

I hope this gives more info what this warning should cause.



iWim

You cannot create overrides for VM sublayouts within Joomla.

You'll have to create the override manually
Use an FTP program (i.e. FileZilla, CyberDuck) or the file manager of your webhost's control panel.

1 Go to the folder ~/components/com_virtuemart/sublayouts
2 Download the file snippets.php to your computer
3 Upload the file to ~/templates/your-template/html/com_virtuemart/sublayouts

Edit the override
4a You can edit snippets.php on your computer (before uploading at #3) with a text editor (i.e Notepad, VSCode (MS), VSCodium (non-MS), Sublime Text) and then upload the edited file to the location at #3.

Or
4b Edit the override in Joomla after you uploaded the file at #3
Go to System > Website Templates > Your Template.
Under tab Editor find and select snippets.php

5 Open the old override (0snippets.php) in a new browser tab.
You should now be able to look at/though both snippets.php and 0snippets.php.

6 In 0snippets.php find the code for Yotpo reviews

7 Copy it into snippets.php

I don't know Yotpo, so I can't say which code it is or at what location in snippets.php it should be.

I do recomend to paste it where you can easily find it again.
Maybe even add a comment like /* Yotpo reviews */

Olive

I did as described by you.

I found the yotpo code in the old snippets.php
Copied into the new snippets.php

It worked.

The warning error is gone and the productreviews from Yotpo are visible.

Thanks a lot Wim!