Process Shortcodes in WooCommerce custom template

MAILPOET-5110
This commit is contained in:
Oluwaseun Olorunsola
2023-03-21 17:14:31 +01:00
committed by Aschepikov
parent 685af267cb
commit c75dc63cc5
2 changed files with 36 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
namespace MailPoet\WooCommerce\TransactionalEmails;
use MailPoet\Cron\Workers\SendingQueue\Tasks\Shortcodes;
use MailPoet\Entities\NewsletterEntity;
use MailPoet\Newsletter\Renderer\Renderer as NewsletterRenderer;
use MailPoetVendor\csstidy;
@@ -33,8 +34,11 @@ class Renderer {
}
public function render(NewsletterEntity $newsletter, ?string $subject = null) {
$renderedHtml = $this->renderer->renderAsPreview($newsletter, 'html', $subject);
$renderedNewsletter = $this->renderer->renderAsPreview($newsletter, 'html', $subject);
$headingText = $subject ?? '';
$renderedHtml = Shortcodes::process($renderedNewsletter, null, $newsletter, null, null);
$renderedHtml = str_replace(ContentPreprocessor::WC_HEADING_PLACEHOLDER, $headingText, $renderedHtml);
$html = explode(ContentPreprocessor::WC_CONTENT_PLACEHOLDER, $renderedHtml);
$this->htmlBeforeContent = $html[0];