Transformers
1 year ago
BaseLocationCountryRuleProcessor.php
2 years ago
BaseLocationStateRuleProcessor.php
2 years ago
ComparisonOperation.php
2 years ago
ContextPluginsRuleProcessor.php
1 year ago
EvaluateAndGetStatus.php
2 years ago
EvaluateOverrides.php
1 year ago
EvaluationLogger.php
1 year ago
FailRuleProcessor.php
2 years ago
GetRuleProcessor.php
2 years ago
GetRuleProcessorForContext.php
1 year ago
IsEcommerceRuleProcessor.php
2 years ago
IsWooExpressRuleProcessor.php
2 years ago
NotRuleProcessor.php
2 years ago
NoteStatusRuleProcessor.php
2 years ago
OnboardingProfileRuleProcessor.php
2 years ago
OptionRuleProcessor.php
2 years ago
OrRuleProcessor.php
2 years ago
OrderCountRuleProcessor.php
2 years ago
OrdersProvider.php
2 years ago
PassRuleProcessor.php
2 years ago
PluginVersionRuleProcessor.php
2 years ago
PluginsActivatedRuleProcessor.php
2 years ago
ProductCountRuleProcessor.php
1 year ago
PublishAfterTimeRuleProcessor.php
2 years ago
PublishBeforeTimeRuleProcessor.php
2 years ago
RuleEvaluator.php
1 year ago
RuleProcessorInterface.php
2 years ago
StoredStateRuleProcessor.php
2 years ago
StoredStateSetupForProducts.php
2 years ago
TotalPaymentsVolumeProcessor.php
1 year ago
WCAdminActiveForProvider.php
2 years ago
WCAdminActiveForRuleProcessor.php
2 years ago
WooCommerceAdminUpdatedRuleProcessor.php
2 years ago
NoteStatusRuleProcessor.php
62 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Rule processor that compares against the status of another note. For |
| 4 | * example, this could be used to conditionally create a note only if another |
| 5 | * note has not been actioned. |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | use Automattic\WooCommerce\Admin\Notes\Notes; |
| 13 | |
| 14 | /** |
| 15 | * Rule processor that compares against the status of another note. |
| 16 | */ |
| 17 | class NoteStatusRuleProcessor implements RuleProcessorInterface { |
| 18 | /** |
| 19 | * Compare against the status of another note. |
| 20 | * |
| 21 | * @param object $rule The rule being processed by this rule processor. |
| 22 | * @param object $stored_state Stored state. |
| 23 | * |
| 24 | * @return bool The result of the operation. |
| 25 | */ |
| 26 | public function process( $rule, $stored_state ) { |
| 27 | $status = Notes::get_note_status( $rule->note_name ); |
| 28 | if ( ! $status ) { |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | return ComparisonOperation::compare( |
| 33 | $status, |
| 34 | $rule->status, |
| 35 | $rule->operation |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Validates the rule. |
| 41 | * |
| 42 | * @param object $rule The rule to validate. |
| 43 | * |
| 44 | * @return bool Pass/fail. |
| 45 | */ |
| 46 | public function validate( $rule ) { |
| 47 | if ( ! isset( $rule->note_name ) ) { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | if ( ! isset( $rule->status ) ) { |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | if ( ! isset( $rule->operation ) ) { |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | return true; |
| 60 | } |
| 61 | } |
| 62 |