Server IP : 104.21.14.103 / Your IP : 3.16.68.121 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/Newsletter/Renderer/Blocks/ |
Upload File : |
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Newsletter\Renderer\Blocks; if (!defined('ABSPATH')) exit; use MailPoet\AutomaticEmails\WooCommerce\Events\AbandonedCart; use MailPoet\AutomaticEmails\WooCommerce\WooCommerce as WooCommerceEmail; use MailPoet\Entities\NewsletterEntity; use MailPoet\Entities\NewsletterOptionEntity; use MailPoet\Tasks\Sending as SendingTask; class AbandonedCartContent { /** @var AutomatedLatestContentBlock */ private $ALCBlock; public function __construct( AutomatedLatestContentBlock $ALCBlock ) { $this->ALCBlock = $ALCBlock; } public function render( NewsletterEntity $newsletter, array $args, bool $preview = false, SendingTask $sendingTask = null ): array { if ( !in_array( $newsletter->getType(), [ NewsletterEntity::TYPE_AUTOMATIC, NewsletterEntity::TYPE_AUTOMATION_TRANSACTIONAL, NewsletterEntity::TYPE_AUTOMATION, ], true ) ) { // Do not display the block if not an automatic email return []; } $groupOption = $newsletter->getOptions()->filter(function (NewsletterOptionEntity $newsletterOption) { $optionField = $newsletterOption->getOptionField(); return $optionField && $optionField->getName() === 'group'; })->first(); $eventOption = $newsletter->getOptions()->filter(function (NewsletterOptionEntity $newsletterOption) { $optionField = $newsletterOption->getOptionField(); return $optionField && $optionField->getName() === 'event'; })->first(); if ( ($groupOption instanceof NewsletterOptionEntity && $groupOption->getValue() !== WooCommerceEmail::SLUG) || ($eventOption instanceof NewsletterOptionEntity && $eventOption->getValue() !== AbandonedCart::SLUG) ) { // Do not display the block if not an AbandonedCart email return []; } if ($preview) { // Display latest products for preview (no 'posts' argument specified) return $this->ALCBlock->render($newsletter, $args); } if (!($sendingTask instanceof SendingTask)) { // Do not display the block if we're not sending an email return []; } $meta = $sendingTask->getMeta(); if (empty($meta[AbandonedCart::TASK_META_NAME])) { // Do not display the block if a cart is empty return []; } $args['amount'] = 50; $args['posts'] = $meta[AbandonedCart::TASK_META_NAME]; return $this->ALCBlock->render($newsletter, $args); } }