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
BaseLocationStateRuleProcessor.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Rule processor that performs a comparison operation against the base |
| 4 | * location - state. |
| 5 | */ |
| 6 | |
| 7 | namespace Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors; |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | /** |
| 12 | * Rule processor that performs a comparison operation against the base |
| 13 | * location - state. |
| 14 | */ |
| 15 | class BaseLocationStateRuleProcessor implements RuleProcessorInterface { |
| 16 | /** |
| 17 | * Performs a comparison operation against the base location - state. |
| 18 | * |
| 19 | * @param object $rule The specific rule being processed by this rule processor. |
| 20 | * @param object $stored_state Stored state. |
| 21 | * |
| 22 | * @return bool The result of the operation. |
| 23 | */ |
| 24 | public function process( $rule, $stored_state ) { |
| 25 | $base_location = wc_get_base_location(); |
| 26 | if ( ! is_array( $base_location ) || ! array_key_exists( 'state', $base_location ) ) { |
| 27 | return false; |
| 28 | } |
| 29 | |
| 30 | return ComparisonOperation::compare( |
| 31 | $base_location['state'], |
| 32 | $rule->value, |
| 33 | $rule->operation |
| 34 | ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Validates the rule. |
| 39 | * |
| 40 | * @param object $rule The rule to validate. |
| 41 | * |
| 42 | * @return bool Pass/fail. |
| 43 | */ |
| 44 | public function validate( $rule ) { |
| 45 | if ( ! isset( $rule->value ) ) { |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | if ( ! isset( $rule->operation ) ) { |
| 50 | return false; |
| 51 | } |
| 52 | |
| 53 | return true; |
| 54 | } |
| 55 | } |
| 56 |