<?php namespace MailPoet\Config; if (!defined('ABSPATH')) exit; use MailPoet\Logging\LoggerFactory; use MailPoet\Segments\WooCommerce as WooCommerceSegment; use MailPoet\Statistics\Track\WooCommercePurchases; use MailPoet\Subscription\Registration; use MailPoet\WooCommerce\Settings as WooCommerceSettings; use MailPoet\WooCommerce\SubscriberEngagement; use MailPoet\WooCommerce\Subscription as WooCommerceSubscription; class HooksWooCommerce { /** @var WooCommerceSubscription */ private $woocommerceSubscription; /** @var WooCommerceSegment */ private $woocommerceSegment; /** @var WooCommerceSettings */ private $woocommerceSettings; /** @var WooCommercePurchases */ private $woocommercePurchases; /** @var Registration */ private $subscriberRegistration; /** @var LoggerFactory */ private $loggerFactory; /** @var SubscriberEngagement */ private $subscriberEngagement; public function __construct( WooCommerceSubscription $woocommerceSubscription, WooCommerceSegment $woocommerceSegment, WooCommerceSettings $woocommerceSettings, WooCommercePurchases $woocommercePurchases, Registration $subscriberRegistration, LoggerFactory $loggerFactory, SubscriberEngagement $subscriberEngagement ) { $this->woocommerceSubscription = $woocommerceSubscription; $this->woocommerceSegment = $woocommerceSegment; $this->woocommerceSettings = $woocommerceSettings; $this->woocommercePurchases = $woocommercePurchases; $this->loggerFactory = $loggerFactory; $this->subscriberRegistration = $subscriberRegistration; $this->subscriberEngagement = $subscriberEngagement; } public function extendWooCommerceCheckoutForm() { try { $this->woocommerceSubscription->extendWooCommerceCheckoutForm(); } catch (\Throwable $e) { $this->logError($e, 'WooCommerce Subscription'); } } public function subscribeOnCheckout($orderId, $data) { try { $this->woocommerceSubscription->subscribeOnCheckout($orderId, $data); } catch (\Throwable $e) { $this->logError($e, 'WooCommerce Subscription'); } } public function disableWooCommerceSettings() { try { $this->woocommerceSettings->disableWooCommerceSettings(); } catch (\Throwable $e) { $this->logError($e, 'WooCommerce Settings'); } } public function synchronizeRegisteredCustomer($wpUserId, $currentFilter = null) { try { $this->woocommerceSegment->synchronizeRegisteredCustomer($wpUserId, $currentFilter); } catch (\Throwable $e) { $this->logError($e, 'WooCommerce Sync'); } } public function synchronizeGuestCustomer($orderId) { try { $this->woocommerceSegment->synchronizeGuestCustomer($orderId); } catch (\Throwable $e) { $this->logError($e, 'WooCommerce Sync'); } } public function trackPurchase($id, $useCookies = true) { try { $this->woocommercePurchases->trackPurchase($id, $useCookies); } catch (\Throwable $e) { $this->logError($e, 'WooCommerce Purchases'); } } public function extendForm() { try { $this->subscriberRegistration->extendForm(); } catch (\Throwable $e) { $this->logError($e, 'WooCommerce Extend Form'); } } public function onRegister($errors, string $userLogin, string $userEmail = null) { try { if (empty($errors->errors)) { $this->subscriberRegistration->onRegister($errors, $userLogin, $userEmail); } } catch (\Throwable $e) { $this->logError($e, 'WooCommerce on Register'); } return $errors; } public function updateSubscriberEngagement($orderId) { try { $this->subscriberEngagement->updateSubscriberEngagement($orderId); } catch (\Throwable $e) { $this->logError($e, 'WooCommerce Update Subscriber Engagement'); } } private function logError(\Throwable $e, $name) { $logger = $this->loggerFactory->getLogger($name); $logger->addError($e->getMessage(), [ 'file' => $e->getFile(), 'line' => $e->getLine(), ]); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
PopulatorData | Folder | 0755 |
|
|
AccessControl.php | File | 3.23 KB | 0644 |
|
Activator.php | File | 2.22 KB | 0644 |
|
AssetsLoader.php | File | 801 B | 0644 |
|
Capabilities.php | File | 2.8 KB | 0644 |
|
Changelog.php | File | 3.9 KB | 0644 |
|
Database.php | File | 2.78 KB | 0644 |
|
DatabaseInitializer.php | File | 601 B | 0644 |
|
DeferredAdminNotices.php | File | 1.07 KB | 0644 |
|
Env.php | File | 3.93 KB | 0644 |
|
Hooks.php | File | 10.32 KB | 0644 |
|
HooksWooCommerce.php | File | 3.97 KB | 0644 |
|
Initializer.php | File | 9.92 KB | 0644 |
|
Installer.php | File | 2.69 KB | 0644 |
|
Localizer.php | File | 1.15 KB | 0644 |
|
MP2Migrator.php | File | 35.34 KB | 0644 |
|
Menu.php | File | 14.04 KB | 0644 |
|
Migrator.php | File | 25.73 KB | 0644 |
|
PersonalDataErasers.php | File | 622 B | 0644 |
|
PersonalDataExporters.php | File | 2.64 KB | 0644 |
|
PluginActivatedHook.php | File | 682 B | 0644 |
|
Populator.php | File | 29.67 KB | 0644 |
|
PrivacyPolicy.php | File | 3.37 KB | 0644 |
|
Renderer.php | File | 3.95 KB | 0644 |
|
RendererFactory.php | File | 474 B | 0644 |
|
RequirementsChecker.php | File | 4.3 KB | 0644 |
|
Router.php | File | 846 B | 0644 |
|
ServicesChecker.php | File | 4.93 KB | 0644 |
|
Shortcodes.php | File | 6.22 KB | 0644 |
|
Updater.php | File | 1.71 KB | 0644 |
|
index.php | File | 0 B | 0644 |
|