AbandonedCartSubject.php
2 years ago
CustomerSubject.php
5 months ago
OrderStatusChangeSubject.php
2 years ago
OrderSubject.php
2 years ago
index.php
3 years ago
OrderStatusChangeSubject.php
49 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Automation\Integrations\WooCommerce\Subjects; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Automation\Engine\Data\Subject as SubjectData; |
| 9 | use MailPoet\Automation\Engine\Integration\Payload; |
| 10 | use MailPoet\Automation\Engine\Integration\Subject; |
| 11 | use MailPoet\Automation\Integrations\WooCommerce\Payloads\OrderStatusChangePayload; |
| 12 | use MailPoet\Validator\Builder; |
| 13 | use MailPoet\Validator\Schema\ObjectSchema; |
| 14 | |
| 15 | /** |
| 16 | * @implements Subject<OrderStatusChangePayload> |
| 17 | */ |
| 18 | class OrderStatusChangeSubject implements Subject { |
| 19 | |
| 20 | const KEY = 'woocommerce:order-status-changed'; |
| 21 | |
| 22 | public function getName(): string { |
| 23 | // translators: automation subject (entity entering automation) title |
| 24 | return __('WooCommerce order status change', 'mailpoet'); |
| 25 | } |
| 26 | |
| 27 | public function getArgsSchema(): ObjectSchema { |
| 28 | return Builder::object([ |
| 29 | 'from' => Builder::string()->required(), |
| 30 | 'to' => Builder::string()->required(), |
| 31 | ]); |
| 32 | } |
| 33 | |
| 34 | public function getPayload(SubjectData $subjectData): Payload { |
| 35 | $from = $subjectData->getArgs()['from']; |
| 36 | $to = $subjectData->getArgs()['to']; |
| 37 | |
| 38 | return new OrderStatusChangePayload($from, $to); |
| 39 | } |
| 40 | |
| 41 | public function getKey(): string { |
| 42 | return self::KEY; |
| 43 | } |
| 44 | |
| 45 | public function getFields(): array { |
| 46 | return []; |
| 47 | } |
| 48 | } |
| 49 |