# overrideProductsByName

Globally override products on any paywall by product name.

## [Purpose](/content/docs/flutter/sdk-reference/overrideProductsByName#purpose/index.html)

Allows you to globally override products on any paywall that have a given name. The key is the product name in the paywall, and the value is the product identifier to replace it with. This is useful for A/B testing different products or dynamically changing products based on user segments.

## [Signature](/content/docs/flutter/sdk-reference/overrideProductsByName#signature/index.html)

```dart
// Setter
set overrideProductsByName(Map<String, String>? overrideProducts)

// Getter
Future<Map<String, String>?> getOverrideProductsByName()
```

## [Parameters](/content/docs/flutter/sdk-reference/overrideProductsByName#parameters/index.html)

| Prop               | Type                      |
|--------------------|---------------------------|
| `overrideProducts?`| Map<String, String>?       |

## [Returns / State](/content/docs/flutter/sdk-reference/overrideProductsByName#returns--state/index.html)

- **Setter**: Sets the global product overrides. Changes take effect immediately for all future paywall presentations.
- **Getter**: Returns a `Future<Map<String, String>?>` containing the current override mapping, or `null` if no overrides are set.

## [Usage](/content/docs/flutter/sdk-reference/overrideProductsByName#usage/index.html)

Setting product overrides:

```dart
// Override products globally
Superwall.shared.overrideProductsByName = {
  'primary': 'com.example.premium_monthly',
  'secondary': 'com.example.premium_annual',
  'tertiary': 'com.example.premium_lifetime',
};

// All paywalls will now use these product identifiers
// instead of the ones configured in the dashboard
```

Clearing overrides:

```dart
// Clear all overrides
Superwall.shared.overrideProductsByName = null;
```

Getting current overrides:

```dart
final overrides = await Superwall.shared.getOverrideProductsByName();
if (overrides != null) {
  print('Current overrides: $overrides');
} else {
  print('No overrides set');
}
```

Dynamic overrides based on user segment:

```dart
void _setProductOverridesForUser(User user) {
  if (user.isPremium) {
    // Premium users get annual products
    Superwall.shared.overrideProductsByName = {
      'primary': 'com.example.premium_annual',
    };
  } else {
    // Regular users get monthly products
    Superwall.shared.overrideProductsByName = {
      'primary': 'com.example.premium_monthly',
    };
  }
}
```

A/B testing different products:

```dart
void _setupProductABTest() {
  final random = Random();
  if (random.nextBool()) {
    // Variant A: Monthly product
    Superwall.shared.overrideProductsByName = {
      'primary': 'com.example.premium_monthly',
    };
  } else {
    // Variant B: Annual product
    Superwall.shared.overrideProductsByName = {
      'primary': 'com.example.premium_annual',
    };
  }
}
```

## [Notes](/content/docs/flutter/sdk-reference/overrideProductsByName#notes/index.html)

- Overrides apply globally to all paywalls that use the specified product names
- Overrides take effect immediately for all future paywall presentations
- You can also set overrides per-paywall using [`PaywallOptions.overrideProductsByName`](/content/docs/flutter/sdk-reference/PaywallOptions#overrideproductsbyname/index.html)
- Per-paywall overrides take precedence over global overrides.
