helper = $helper; } public function render($element, $columnBaseWidth) { $couponCode = self::CODE_PLACEHOLDER; if (!empty($element['couponId'])) { try { $couponCode = $this->helper->wcGetCouponCodeById((int)$element['couponId']); } catch (\Exception $e) { if (!$this->helper->isWooCommerceActive()) { throw NewsletterProcessingException::create()->withMessage(__('WooCommerce is not active', 'mailpoet')); } else { throw NewsletterProcessingException::create()->withMessage($e->getMessage())->withCode($e->getCode()); } } if (empty($couponCode)) { throw NewsletterProcessingException::create()->withMessage(__('Couldn\'t find the coupon. Please update the email if the coupon was removed.', 'mailpoet')); } } $element['styles']['block']['width'] = $this->calculateWidth($element, $columnBaseWidth); $styles = 'display:inline-block;-webkit-text-size-adjust:none;mso-hide:all;text-decoration:none;text-align:center;' . StylesHelper::getBlockStyles($element, $exclude = ['textAlign']); $styles = EHelper::escapeHtmlStyleAttr($styles); $template = '
' . EHelper::escapeHtmlText($couponCode) . '
|