ResolutionStrategy Interface
Interface for a resolution strategy.
Namespace
Usage
When you implement this interface, you can register your apex class just like an extension provider class. Your class can then conditionally decide how to handle each extension invocation. You can delegate to a specific extension provider, you can execute default domain logic, or you can execute no logic at all.
ResolutionStrategy Methods
The following are methods for ResolutionStrategy.
resolve()
Returns a resolution object, which indicates how the resolution strategy was resolved.
The resolution indicates whether default logic, extension provider logic, or no logic is
executed.
Signature
public CommerceExtension.Resolution resolve()
Return Value
Type: CommerceExtension.Resolution
Resolution object that indicates how the resolution strategy was resolved.
ResolutionStrategy Example Implementation
This is an example implementation of the CommerceExtension.ResolutionStrategy interface.
1// This sample is for the situation when different tax behaviors need to be
2// implemented for different locales.
3//
4// These tax behaviors can be -
5// 1. ResolutionState - EXECUTE_DEFAULT (the default Salesforce Internal Tax Api).
6// 2. ResolutionState - EXECUTE_REGISTERED (extended or overridden implementations
7// via the extension point from the default Salesforce Internal Tax Api)
8// 3. ResolutionState - OFF (In this case, the default Salesforce Internal Tax Api
9// will return an empty response).
10//
11// An Extension Provider is a custom apex class which extends or overrides the
12// default Salesforce Internal Tax Api.
13//
14// An Extension Resolver is a custom apex class which selects different resolution
15// states (EXECUTE_DEFAULT, EXECUTE_REGISTERED and OFF) for different locales
16// to execute respective implementations (Extension Providers or the Default
17// Salesforce Internal Tax Api).
18
19// Your custom apex extension providers and the resolver must be registered with
20// the tax extension point and then the resolver must be registered and mapped to
21// the web store via appropriate setup.
22//
23// You can have as many Extension Providers registered as per your use case and
24// select them in your resolver for different locales.
25//
26// Please follow the corresponding salesforce documentation on how to use locales.
27// For more information related to that, please see the corresponding documentation.
28
29// This must implement the commercestoretax.TaxService class in order to be
30// processed by the tax service flow. It must also implement the
31// CommerceExtension.ResolutionStrategy in order to work as a extension resolver
32// and get the different locales and resolutions.
33//
34public class TaxServiceExtensionResolverSample
35 extends commercestoretax.TaxService
36 implements CommerceExtension.ResolutionStrategy {
37
38 public CommerceExtension.Resolution resolve() {
39 // The Sample Extension Provider registered with developer name as
40 // 'tax_extension_provider_for_us' will be selected for execution for en_US locale
41 if (CommerceExtension.ExtensionInfo.getLocaleString() == 'en_US') {
42 return new CommerceExtension.Resolution('tax_extension_provider_for_us');
43 }
44 // The Sample Extension Provider registered with developer name as
45 // 'tax_extension_provider_for_canada' will be selected for execution for en_CA locale
46 if (CommerceExtension.ExtensionInfo.getLocaleString() == 'en_CA') {
47 return new CommerceExtension.Resolution('tax_extension_provider_for_canada');
48 }
49 // The default Salesforce Internal Tax Api will return an empty response for German locale
50 if (CommerceExtension.ExtensionInfo.getLocaleString() == 'de') {
51 return new CommerceExtension.Resolution(
52 CommerceExtension.ResolutionStates.OFF
53 );
54 }
55 // The default Salesforce Internal Tax Api will be selected for execution for
56 // all other locales than US, Canada and Germany
57 return new CommerceExtension.Resolution();
58 }
59}