Automattic\WooCommerce\Admin\Features\ShippingPartnerSuggestions
ShippingPartnerSuggestions::get_suggestions
Go through the specs and run them.
Метод класса: ShippingPartnerSuggestions{}
Хуков нет.
Возвращает
array.
Использование
$result = ShippingPartnerSuggestions::get_suggestions( ?array $specs );
- ?array $specs
- .
По умолчанию:null
Код ShippingPartnerSuggestions::get_suggestions() ShippingPartnerSuggestions::get suggestions WC 11.2.2
public static function get_suggestions( ?array $specs = null ) {
$locale = get_user_locale();
$specs = is_array( $specs ) ? $specs : self::get_specs();
$results = EvaluateSuggestion::evaluate_specs( $specs, array( 'source' => 'wc-shipping-partner-suggestions' ) );
$specs_to_return = $results['suggestions'];
$specs_to_save = null;
if ( empty( $specs_to_return ) ) {
// When suggestions is empty, replace it with defaults and save for 3 hours.
$specs_to_save = DefaultShippingPartners::get_all();
$specs_to_return = EvaluateSuggestion::evaluate_specs( $specs_to_save, array( 'source' => 'wc-shipping-partner-suggestions' ) )['suggestions'];
} elseif ( count( $results['errors'] ) > 0 ) {
// When suggestions is not empty but has errors, save it for 3 hours.
$specs_to_save = $specs;
}
if ( $specs_to_save ) {
ShippingPartnerSuggestionsDataSourcePoller::get_instance()->set_specs_transient( array( $locale => $specs_to_save ), 3 * HOUR_IN_SECONDS );
}
return self::sort_by_primary( $specs_to_return );
}