1

I've got a shortcode setup using the Shortcoder plugin. It returns some text that I've defined (which will be changed on a weekly basis).

I'm trying to simplify weekly changes as much as possible for my client.

Using this shortcode is great - because I can put the same text anywhere on the site, and it will automatically update when I update the content of that shortcode.

However, I'm trying to get it to work within a WooCommerce email - which doesn't work, because it's obviously off the site so can't 'translate' the shortcode.

Is there any way that I could either:

a) Make the email template take the value of the shortcode and output it in the HTML email b) When a customer places their order, WooCommerce takes the value of the shortcode and inputs this into the DB, so I can then call this in the email?

Any help appreciated.

3
  • 1
    Hard to say without seeing how you're generating the email in the first place but maybe you'd want to use the apply_shortcodes() function to get the output of your shortcode (eg. $my_shortcode_contents = apply_shortcodes('[my_shortcode]');) and then pass it to the email somehow? Commented Apr 16, 2020 at 16:18
  • Thanks @cabrerahector - I'm generating the email using WooCommerce. It's the Processing Order email. I'm just amending the PHP template. Commented Apr 16, 2020 at 16:23
  • Got it. Then what I suggested earlier will probably get you on the right track :) Commented Apr 16, 2020 at 16:45

1 Answer 1

2

I've managed to sort this. Popping it here in case it helps someone in the future.

   $collection  = do_shortcode( '[sc name="collection"]' );
   <p>Your order collection date is <?php echo $collection; ?>.</p>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.