From 1c89c6e932ce6485b35112652780dc2179e2ca78 Mon Sep 17 00:00:00 2001 From: Berry Hijwegen <43235123+berryhijwegen@users.noreply.github.com> Date: Mon, 29 May 2023 22:00:39 +0200 Subject: [PATCH] woocommerce product support (#158) --- wp-graphql-yoast-seo.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wp-graphql-yoast-seo.php b/wp-graphql-yoast-seo.php index c1135a1..12d4270 100755 --- a/wp-graphql-yoast-seo.php +++ b/wp-graphql-yoast-seo.php @@ -842,6 +842,18 @@ function get_post_type_graphql_fields($post, array $args, AppContext $context) return get_post_type_graphql_fields($post, $args, $context); }, ]); + + // if woocommerce is active, add seo to product + if (class_exists('WooCommerce')) { + register_graphql_field('Product', 'seo', [ + 'type' => 'PostTypeSEO', + 'description' => __('The Yoast SEO data of the ContentNode', 'wp-graphql-yoast-seo'), + 'resolve' => function ($post, array $args, AppContext $context) { + return get_post_type_graphql_fields($post, $args, $context); + }, + ]); + } + // TODO connect to content node // Post Type SEO Data if (!empty($post_types) && is_array($post_types)) {