Use RegularLabs snippets in email

  • Posts: 359
  • Thank you received: 24
  • Hikaserial Standard Hikashop Business
3 years 9 months ago #329051

-- 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

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 9 months ago #329094

Hi,

You can but you need to add a bit of PHP around the tag, like that:

<?php echo JHTML::_('content.prepare','{snippet my-first-snippet}'); ?>

Please Log in or Create an account to join the conversation.

  • Posts: 359
  • Thank you received: 24
  • Hikaserial Standard Hikashop Business
3 years 9 months ago #329097

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?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 9 months ago #329106

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.

Please Log in or Create an account to join the conversation.

  • Posts: 359
  • Thank you received: 24
  • Hikaserial Standard Hikashop Business
3 years 9 months ago #329196

NP!

I'll hear RegularLabs on this :-)

Please Log in or Create an account to join the conversation.

  • Posts: 359
  • Thank you received: 24
  • Hikaserial Standard Hikashop Business
3 years 9 months ago #329212

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');

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 9 months ago #329222

Hi,

That's great news ! Then it's easy.
Instead of the code:

<?php echo JHTML::_('content.prepare','{snippet handelsbetingelser}'); ?>
use the code:
<?php JPluginHelper::importPlugin('content'); echo JHTML::_('content.prepare','{snippet handelsbetingelser}'); ?>
and it will work.

Please Log in or Create an account to join the conversation.

  • Posts: 359
  • Thank you received: 24
  • Hikaserial Standard Hikashop Business
3 years 9 months ago #329247

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.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 9 months ago #329254

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 ?

Please Log in or Create an account to join the conversation.

  • Posts: 359
  • Thank you received: 24
  • Hikaserial Standard Hikashop Business
3 years 9 months ago #329276

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!

Please Log in or Create an account to join the conversation.

Time to create page: 0.071 seconds
Powered by Kunena Forum