Do you want to create a YayMail custom shortcode and embed it on your website? if you are looking for a simple guide, keep reading this article.
If you are running a customer-centric business, you know the importance of elegant email templates. While the WordPress CMS doesn’t have fancy options to tweak the templates, the YayMail plugin is here to help.
With the help of it, you can create stunning email templates without hassle. Since the plugin also comes with a bunch of shortcodes you can use, adding certain information to the templates would be a cakewalk.
But do you want a method to create a YayMail custom shortcode?
If you are looking for a simple guide for the task, keep reading this article. Here is everything you need to know about creating a YayMail custom shortcode.
But first, let’s see why you need to create a YayMail custom shortcode on your website.
Why You Should Create a YayMail Custom Shortcode
By creating your shortcodes, you gain more control over the content of your emails. You’re not limited to the predefined options but can introduce new variables or data points. This flexibility can be crucial for businesses with unique requirements or for those wanting to stand out with highly tailored communications.
Also, custom shortcodes can automate including complex data or calculations in your emails. For example, you might create a shortcode that calculates the total savings from a customer’s order or one that pulls in real-time inventory status. This reduces manual work and ensures accuracy in the information sent out.
Plus, you can embed marketing messages or branding elements more effectively. You could create a shortcode that dynamically adds a call-to-action based on the customer’s last purchase or one that injects a loyalty program’s current status. This level of customization can significantly enhance marketing efforts within transactional emails.
Now you know why you should create a YayMail custom shortcode. In the next section, we will show you how you can do this task.
How to Create a YayMail Custom Shortcode
We will be dealing with some codes for this. So, you might want to generate a complete website backup and store it offsite. If anything goes bad, you could use the recent backup to get the website to its previous state.
Once you have generated the backup, you can start adding the code. To add the code, you can use a site-specific plugin like Code Snippets or use the functions.php file of your child theme.
For this tutorial, we will use Code Snippets.
You need to install and activate this plugin on your website.
After activation, you can see the plugin’s settings on the left-hand side.
There, add a new snippet.
If you are going to use the theme’s functions.php file for editing, you can skip these steps.
With the help of the yaymail_custom_shortcode_[‘name’] filter, you can create custom shortcodes on the platform.
Here’s an example of the code you can use:
add_filter(
'yaymail_customs_shortcode',
function( $shortcode_list, $yaymail_informations, $args = array() ) {
$shortcode_list['[yaymail_custom_shortcode_new_order]'] = 'Custom shortcode test New order';
$shortcode_list['[yaymail_custom_shortcode_processing_order]'] = 'Custom shortcode test Processing order';
$shortcode_list['[yaymail_custom_shortcode_order_on_hold]'] = 'Custom shortcode test Order on hold';
return $shortcode_list;
},
10,
3
);
As you can see in the code, we have added three new shortcodes in the plugin.
- New order
- Processing order
- Order on hold
What you need to do is copy the code and save it as a new snippet.
After saving the code, open the YayMail settings and click the shortcode option which is on the top section.
If you scroll to the bottom, you can see all the newly created shortcodes.
As you can see in the screenshot, all the shortcodes have been added to the YayMail plugin. When you tweak the email templates of your blog or online store, you can use these options.
Here is another example code you can use:
function test_shortcode1( $shortcode_list, $yaymail_informations, $args = array() ) {
//It only runs when tested with real order
if (isset ($args['order'])) {
$order = $args['order'];
$order_id = $order->get_id();
return $order_id;
}
// in Yaymail will show it
return 'test_shortcode';
}
add_filter(
'yaymail_customs_shortcode',
function( $shortcode_list, $yaymail_informations, $args = array() ) {
$shortcode_list['[yaymail_custom_shortcode_test]'] = test_shortcode1($shortcode_list, $yaymail_informations, $args);
return $shortcode_list;
},
10,
3
);
You can use this one or the code we mentioned earlier. As per your requirement, you can change the code.
If you need any help with the coding or need support, check out our documentation article. Otherwise, you can also raise a support ticket to get in touch with one of our experienced support staff.
That’s it!
This is how you can create a YayMail custom shortcode.
Frequently Asked Question
Next, let’s see some frequently asked questions and answers.
A custom shortcode in YayMail is a small piece of code you can create to insert dynamic or unique content into your email templates. It allows you to personalize emails beyond the standard options by pulling in specific data or executing custom logic.
While basic coding knowledge can be helpful, you don’t necessarily need to be a coding expert. YayMail provides a user-friendly environment where you can define shortcodes with simple placeholders that the plugin will then interpret and populate with the correct data.
Absolutely, custom shortcodes can be used to enhance your marketing efforts by inserting personalized promotions, tracking codes, or even dynamic content that changes based on customer behavior or purchase history, making your emails more engaging and relevant.
While YayMail is designed to handle customization efficiently, using an excessive number of complex custom shortcodes might slow down email generation. It’s best to use them judiciously, focusing on those that add significant value or personalization to your emails.
Conclusion
Creating custom shortcodes in YayMail can transform how you communicate with your customers through email.
By tailoring each message with personalized content, you not only enhance the customer experience but also leverage your emails as a powerful marketing tool.
The process, while it might seem technical at first, is made accessible through YayMail’s intuitive interface, ensuring that even those with minimal coding skills can benefit.
Remember, the key to success lies in using these shortcodes to add value, not just for the sake of customization. Whether it’s for better engagement, increased sales, or simply making each customer feel uniquely valued, custom shortcodes can significantly elevate your WooCommerce store’s email strategy.
So we highly recommend testing out this function.
Which shortcode are you going to include?
Let us know in the comments.