diff --git a/plugins/woocommerce-admin/src/RemoteInboxNotifications/BaseLocationCountryRuleProcessor.php b/plugins/woocommerce-admin/src/RemoteInboxNotifications/BaseLocationCountryRuleProcessor.php new file mode 100644 index 00000000000..b517810c840 --- /dev/null +++ b/plugins/woocommerce-admin/src/RemoteInboxNotifications/BaseLocationCountryRuleProcessor.php @@ -0,0 +1,55 @@ +value, + $rule->operation + ); + } + + /** + * Validates the rule. + * + * @param object $rule The rule to validate. + * + * @return bool Pass/fail. + */ + public function validate( $rule ) { + if ( ! isset( $rule->value ) ) { + return false; + } + + if ( ! isset( $rule->operation ) ) { + return false; + } + + return true; + } +} diff --git a/plugins/woocommerce-admin/src/RemoteInboxNotifications/BaseLocationStateRuleProcessor.php b/plugins/woocommerce-admin/src/RemoteInboxNotifications/BaseLocationStateRuleProcessor.php new file mode 100644 index 00000000000..f2f70c3c4ab --- /dev/null +++ b/plugins/woocommerce-admin/src/RemoteInboxNotifications/BaseLocationStateRuleProcessor.php @@ -0,0 +1,55 @@ +value, + $rule->operation + ); + } + + /** + * Validates the rule. + * + * @param object $rule The rule to validate. + * + * @return bool Pass/fail. + */ + public function validate( $rule ) { + if ( ! isset( $rule->value ) ) { + return false; + } + + if ( ! isset( $rule->operation ) ) { + return false; + } + + return true; + } +} diff --git a/plugins/woocommerce-admin/src/RemoteInboxNotifications/GetRuleProcessor.php b/plugins/woocommerce-admin/src/RemoteInboxNotifications/GetRuleProcessor.php index d46ea442c8a..d21229b7e5f 100644 --- a/plugins/woocommerce-admin/src/RemoteInboxNotifications/GetRuleProcessor.php +++ b/plugins/woocommerce-admin/src/RemoteInboxNotifications/GetRuleProcessor.php @@ -48,6 +48,10 @@ class GetRuleProcessor { return new OnboardingProfileRuleProcessor(); case 'is_ecommerce': return new IsEcommerceRuleProcessor(); + case 'base_location_country': + return new BaseLocationCountryRuleProcessor(); + case 'base_location_state': + return new BaseLocationStateRuleProcessor(); } return new FailRuleProcessor(); diff --git a/plugins/woocommerce-admin/src/RemoteInboxNotifications/README.md b/plugins/woocommerce-admin/src/RemoteInboxNotifications/README.md index fd64229a9db..c47a9fabf28 100644 --- a/plugins/woocommerce-admin/src/RemoteInboxNotifications/README.md +++ b/plugins/woocommerce-admin/src/RemoteInboxNotifications/README.md @@ -342,4 +342,30 @@ This passes when the store is on a WordPress.com site with the eCommerce plan. `value` is required. +### Base location - country +This passes when the store is located in the specified country. + +``` +{ + "type": "base_location_country", + "value": "US", + "operation": "=" +} +``` + +`value` and `operation` are both required. + +### Base location - state +This passes when the store is located in the specified state. + +``` +{ + "type": "base_location_state", + "value": "TX", + "operation": "=" +} +``` + +`value` and `operation` are both required. +