Fields
2 months ago
Payloads
1 year ago
SubjectTransformers
2 months ago
Subjects
5 months ago
Triggers
2 months ago
ContextFactory.php
2 months ago
WooCommerce.php
2 months ago
WooCommerceIntegration.php
2 months ago
index.php
3 years ago
ContextFactory.php
34 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Automation\Integrations\WooCommerce; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | class ContextFactory { |
| 9 | |
| 10 | /** @var WooCommerce */ |
| 11 | private $woocommerce; |
| 12 | |
| 13 | public function __construct( |
| 14 | WooCommerce $woocommerce |
| 15 | ) { |
| 16 | $this->woocommerce = $woocommerce; |
| 17 | } |
| 18 | |
| 19 | /** @return mixed[] */ |
| 20 | public function getContextData(): array { |
| 21 | |
| 22 | if (!$this->woocommerce->isWooCommerceActive()) { |
| 23 | return []; |
| 24 | } |
| 25 | |
| 26 | $context = [ |
| 27 | 'order_statuses' => $this->woocommerce->wcGetOrderStatuses(), |
| 28 | 'paid_statuses' => $this->woocommerce->wcGetIsPaidStatuses(), |
| 29 | 'review_ratings_enabled' => $this->woocommerce->wcReviewRatingsEnabled(), |
| 30 | ]; |
| 31 | return $context; |
| 32 | } |
| 33 | } |
| 34 |