<?php declare(strict_types = 1); namespace MailPoet\WooCommerce; if (!defined('ABSPATH')) exit; use MailPoet\Entities\SubscriberEntity; use MailPoet\Subscribers\SubscribersRepository; use WC_Order; class SubscriberEngagement { /** @var Helper */ private $woocommerceHelper; /** @var SubscribersRepository */ private $subscribersRepository; public function __construct( Helper $woocommerceHelper, SubscribersRepository $subscribersRepository ) { $this->woocommerceHelper = $woocommerceHelper; $this->subscribersRepository = $subscribersRepository; } public function updateSubscriberEngagement($orderId): void { $order = $this->woocommerceHelper->wcGetOrder($orderId); if (!$order instanceof WC_Order) { return; } $subscriber = $this->subscribersRepository->findOneBy(['email' => $order->get_billing_email()]); if (!$subscriber instanceof SubscriberEntity) { return; } $this->subscribersRepository->maybeUpdateLastEngagement($subscriber); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
TransactionalEmails | Folder | 0755 |
|
|
Helper.php | File | 1.73 KB | 0644 |
|
Settings.php | File | 1.04 KB | 0644 |
|
SubscriberEngagement.php | File | 1 KB | 0644 |
|
Subscription.php | File | 6.75 KB | 0644 |
|
TransactionalEmailHooks.php | File | 4.12 KB | 0644 |
|
TransactionalEmails.php | File | 5.01 KB | 0644 |
|
index.php | File | 0 B | 0644 |
|