Automattic\WooCommerce\Internal\Admin\Suggestions
PaymentExtensionSuggestions::get_country_extensions()
Get the list of payment extensions details for a specific country.
Method of the class: PaymentExtensionSuggestions{}
No Hooks.
Return
Array
. The list of payment extensions (their full details) for the given country. Empty array if no extensions are available for the country or the country is not supported.
Usage
$PaymentExtensionSuggestions = new PaymentExtensionSuggestions(); $PaymentExtensionSuggestions->get_country_extensions( $country_code, $context ): array;
- $country_code(string) (required)
- The two-letter country code.
- $context(string)
- The context ID of where these extensions are being used.
Default: ''
PaymentExtensionSuggestions::get_country_extensions() PaymentExtensionSuggestions::get country extensions code WC 9.6.0
public function get_country_extensions( string $country_code, string $context = '' ): array { $country_code = strtoupper( $country_code ); if ( empty( $this->country_extensions[ $country_code ] ) || ! is_array( $this->country_extensions[ $country_code ] ) ) { return array(); } // Process the extensions. $processed_extensions = array(); $priority = 0; foreach ( $this->country_extensions[ $country_code ] as $key => $details ) { // Check the formats we support. if ( is_int( $key ) && is_string( $details ) ) { $extension_id = $details; $extension_country_details = array(); } elseif ( is_string( $key ) && is_array( $details ) ) { $extension_id = $key; $extension_country_details = $details; } else { // Just ignore the entry as it is malformed. continue; } // Determine if the extension should be included based on the store's state, the provided country and context. if ( ! $this->is_extension_allowed( $extension_id, $country_code, $context ) ) { continue; } $extension_base_details = $this->get_extension_base_details( $extension_id ) ?? array(); $extension_details = $this->with_country_details( $extension_base_details, $extension_country_details ); // Check if there is an incentive for this extension and attach its details. $incentive = $this->get_extension_incentive( $extension_id, $country_code, $context ); if ( is_array( $incentive ) && ! empty( $incentive ) ) { $extension_details['_incentive'] = $incentive; } // Include the extension ID. $extension_details['id'] = $extension_id; // Lock in the priority for ordering purposes. // We respect the order in the country extensions list. // We use increments of 10 to allow for easy insertions. $priority += 10; $extension_details['_priority'] = $priority; $processed_extensions[] = $this->standardize_extension_details( $extension_details ); } return $processed_extensions; }