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
IsWooExpressRuleProcessor.php
70 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Rule processor that passes (or fails) when the site is on a Woo Express plan. |
| 4 | * |
| 5 | * @package WooCommerce\Admin\Classes |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | /** |
| 13 | * Rule processor that passes (or fails) when the site is on a Woo Express plan. |
| 14 | * You may optionally pass a plan name to target a specific Woo Express plan. |
| 15 | */ |
| 16 | class IsWooExpressRuleProcessor implements RuleProcessorInterface { |
| 17 | /** |
| 18 | * Passes (or fails) based on whether the site is a Woo Express plan. |
| 19 | * |
| 20 | * @param object $rule The rule being processed by this rule processor. |
| 21 | * @param object $stored_state Stored state. |
| 22 | * |
| 23 | * @return bool The result of the operation. |
| 24 | */ |
| 25 | public function process( $rule, $stored_state ) { |
| 26 | if ( ! function_exists( 'wc_calypso_bridge_is_woo_express_plan' ) ) { |
| 27 | return false === $rule->value; |
| 28 | } |
| 29 | |
| 30 | // If the plan is undefined, only check if it's a Woo Express plan. |
| 31 | if ( ! isset( $rule->plan ) ) { |
| 32 | return wc_calypso_bridge_is_woo_express_plan() === $rule->value; |
| 33 | } |
| 34 | |
| 35 | // If a plan name is defined, only evaluate the plan if we're on the Woo Express plan. |
| 36 | if ( wc_calypso_bridge_is_woo_express_plan() ) { |
| 37 | $fn = 'wc_calypso_bridge_is_woo_express_' . (string) $rule->plan . '_plan'; |
| 38 | if ( function_exists( $fn ) ) { |
| 39 | return $fn() === $rule->value; |
| 40 | } |
| 41 | |
| 42 | // If an invalid plan name is given, only evaluate the rule if we're targeting all plans other than the specified (invalid) one. |
| 43 | return false === $rule->value; |
| 44 | } |
| 45 | |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Validate the rule. |
| 51 | * |
| 52 | * @param object $rule The rule to validate. |
| 53 | * |
| 54 | * @return bool Pass/fail. |
| 55 | */ |
| 56 | public function validate( $rule ) { |
| 57 | if ( ! isset( $rule->value ) ) { |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | if ( isset( $rule->plan ) ) { |
| 62 | if ( ! function_exists( 'wc_calypso_bridge_is_woo_express_plan' ) ) { |
| 63 | return false; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | return true; |
| 68 | } |
| 69 | } |
| 70 |