Files
wp-graphql-woocommerce/includes/functions.php
T

55 lines
1.0 KiB
PHP
Raw Normal View History

2019-11-14 20:13:26 -05:00
<?php
/**
* Misc functions.
*
* @package WPGraphQL\WooCommerce
* @since 0.3.1
2021-07-06 20:20:47 -04:00
* @deprecated v0.10.2
*
* Will be removed in v0.11.0
2019-11-14 20:13:26 -05:00
*/
namespace WPGraphQL\WooCommerce\Functions;
/**
* Initializes minor integrations with other WordPress plugins.
2023-06-13 23:17:02 +03:00
*
* @return void
2019-11-14 20:13:26 -05:00
*/
function setup_minor_integrations() {
add_filter(
'graphql_swp_result_possible_types',
'WPGraphQL\WooCommerce\Functions\woographql_swp_result_possible_types',
10,
1
);
}
/**
* QL Search integration - Adds to product types to the SWPResult possible types
*
* @param array $type_names SWPResults possible types.
2023-06-13 23:17:02 +03:00
*
2019-11-14 20:13:26 -05:00
* @return array
*/
function woographql_swp_result_possible_types( array $type_names ) {
2019-11-14 20:13:26 -05:00
if ( in_array( 'Product', $type_names, true ) ) {
$type_names = array_merge(
array_filter(
$type_names,
static function ( $type_name ) {
2019-11-14 20:13:26 -05:00
return 'Product' !== $type_name;
}
),
[
2019-11-14 20:13:26 -05:00
'SimpleProduct',
'VariableProduct',
'GroupProduct',
'ExternalProduct',
]
2019-11-14 20:13:26 -05:00
);
}
return $type_names;
}