- Posts: 366
- Thank you received: 26
Use RegularLabs snippets in email
5 years 8 months ago #329051
by Thrane
Use RegularLabs snippets in email was created by Thrane
-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.24
-- PHP version -- : 7.4
Hi
Is there any way I can use Snippets from RegularLabs in the emails sent to the customer?
regularlabs.com/extensions/snippets
I tried adding the snippet to the emails, but I don't get any output.
Kind regards
Thomas
-- Joomla version -- : 3.9.24
-- PHP version -- : 7.4
Hi
Is there any way I can use Snippets from RegularLabs in the emails sent to the customer?
regularlabs.com/extensions/snippets
I tried adding the snippet to the emails, but I don't get any output.
Kind regards
Thomas
Please Log in or Create an account to join the conversation.
5 years 8 months ago #329094
by nicolas
Replied by nicolas on topic Use RegularLabs snippets in email
Hi,
You can but you need to add a bit of PHP around the tag, like that:
You can but you need to add a bit of PHP around the tag, like that:
Code:
<?php echo JHTML::_('content.prepare','{snippet my-first-snippet}'); ?>
Please Log in or Create an account to join the conversation.
5 years 8 months ago #329097
by Thrane
Replied by Thrane on topic Use RegularLabs snippets in email
Thanks ...
Tried in Order status notification in the HTML version
<?php echo JHTML::_('content.prepare','{snippet handelsbetingelser}'); ?>
But I don't get anything in the email?
Tried in Order status notification in the HTML version
<?php echo JHTML::_('content.prepare','{snippet handelsbetingelser}'); ?>
But I don't get anything in the email?
Please Log in or Create an account to join the conversation.
5 years 8 months ago #329106
by nicolas
Replied by nicolas on topic Use RegularLabs snippets in email
Hi,
Ah my bad, I checked and I can see that the snippet plugin is a system plugin, not a content plugin.
In that case, it won't work in emails as the snippet plugin will only replace the tags at the end of the page processing.
So for that code to work, it would require the plugin to handle the content trigger of Joomla. I think it would be technically possible to add that capability to the plugin as an extra option but you would have to check with RegularLabs.
Ah my bad, I checked and I can see that the snippet plugin is a system plugin, not a content plugin.
In that case, it won't work in emails as the snippet plugin will only replace the tags at the end of the page processing.
So for that code to work, it would require the plugin to handle the content trigger of Joomla. I think it would be technically possible to add that capability to the plugin as an extra option but you would have to check with RegularLabs.
Please Log in or Create an account to join the conversation.
5 years 8 months ago #329196
by Thrane
Replied by Thrane on topic Use RegularLabs snippets in email
NP!
I'll hear RegularLabs on this
I'll hear RegularLabs on this
Please Log in or Create an account to join the conversation.
5 years 8 months ago #329212
by Thrane
Replied by Thrane on topic Use RegularLabs snippets in email
Hi
I got this reply:
"In that case, it won't work in emails as the snippet plugin will only replace the tags at the end of the page processing."
This is not true.
The Snippets plugin is a system plugin, but it includes the onContentPrepareForm function.
So all HikaShop has to do in not just import the content plugins, but also the system plugins:
JPluginHelper::importPlugin('system');
JPluginHelper::importPlugin('content');
I got this reply:
"In that case, it won't work in emails as the snippet plugin will only replace the tags at the end of the page processing."
This is not true.
The Snippets plugin is a system plugin, but it includes the onContentPrepareForm function.
So all HikaShop has to do in not just import the content plugins, but also the system plugins:
JPluginHelper::importPlugin('system');
JPluginHelper::importPlugin('content');
Please Log in or Create an account to join the conversation.
5 years 8 months ago #329222
by nicolas
Replied by nicolas on topic Use RegularLabs snippets in email
Hi,
That's great news ! Then it's easy.
Instead of the code:
use the code:
and it will work.
That's great news ! Then it's easy.
Instead of the code:
Code:
<?php echo JHTML::_('content.prepare','{snippet handelsbetingelser}'); ?>
Code:
<?php JPluginHelper::importPlugin('content'); echo JHTML::_('content.prepare','{snippet handelsbetingelser}'); ?>
Please Log in or Create an account to join the conversation.
5 years 8 months ago #329247
by Thrane
Replied by Thrane on topic Use RegularLabs snippets in email
I tried in the HTML version, but I don't get the text in the email.
Please Log in or Create an account to join the conversation.
5 years 8 months ago #329254
by nicolas
Replied by nicolas on topic Use RegularLabs snippets in email
Hi,
Well, I did a test on my end and it works just fine.
I've created a snippet :
monosnap.com/file/RSJWz82McILscmHSqHknUGeZnMWsSV
and added it in an email:
monosnap.com/file/bDEJQfcezAsxm51EwtlTW3HJzUm0Tc
And then I used the "preview" button and I got the snippet replaced:
monosnap.com/file/dPpLhurgzgYXDdJJfgPWEGuYr3na4L
Just in case I also tried to create an order to make sure that the snippet is replaced in the email received by the customer and it is.
So I don't see why it wouldn't work on your website. Now, I don't know how that extension internal workings and I discovered it 4 days ago...So hard to say why it wouldn't work for you. Would there be a typo in your snippet ? Or it's not published ?
Well, I did a test on my end and it works just fine.
I've created a snippet :
monosnap.com/file/RSJWz82McILscmHSqHknUGeZnMWsSV
and added it in an email:
monosnap.com/file/bDEJQfcezAsxm51EwtlTW3HJzUm0Tc
And then I used the "preview" button and I got the snippet replaced:
monosnap.com/file/dPpLhurgzgYXDdJJfgPWEGuYr3na4L
Just in case I also tried to create an order to make sure that the snippet is replaced in the email received by the customer and it is.
So I don't see why it wouldn't work on your website. Now, I don't know how that extension internal workings and I discovered it 4 days ago...So hard to say why it wouldn't work for you. Would there be a typo in your snippet ? Or it's not published ?
Please Log in or Create an account to join the conversation.
5 years 8 months ago #329276
by Thrane
Replied by Thrane on topic Use RegularLabs snippets in email
Hi Nicolas
Thanks, not sure why, but I got it to work now ...
I think it's a great way to add terms to the email and have the exact same terms elsewhere.
Have a great day!
Thanks, not sure why, but I got it to work now ...
I think it's a great way to add terms to the email and have the exact same terms elsewhere.
Have a great day!
Please Log in or Create an account to join the conversation.
Time to create page: 0.223 seconds