Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- fix: Fix type conflicts on Product interfaces in WooGraphQL 0.21.1+. Props @robbiebel 🙌
- chore: bump PHPStan to v2.0.x
- chore: Test compatibility with WordPress 6.8 and WPGraphQL 2.3.
- chore: Update Composer dev-dependencies and lint.
Expand Down
12 changes: 10 additions & 2 deletions bin/_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,19 @@ install_woographql() {

echo "Installing WooCommerce..."
if ! $(wp plugin is-installed woocommerce); then
wp plugin install woocommerce --activate
wp plugin install woocommerce --activate --allow-root
fi

if ! $(wp plugin is-installed wp-graphql-woocommerce); then
wp plugin install https://github.com/wp-graphql/wp-graphql-woocommerce/releases/download/v0.21.0/wp-graphql-woocommerce.zip --activate
wp plugin install https://github.com/wp-graphql/wp-graphql-woocommerce/archive/refs/heads/master.zip --allow-root
cd $WP_CORE_DIR/wp-content/plugins/wp-graphql-woocommerce

if [ ! -d vendor ]; then
composer install --no-dev
fi

wp plugin activate wp-graphql-woocommerce --allow-root

fi
}

Expand Down
35 changes: 35 additions & 0 deletions src/Extensions/WPGraphQLWooCommerce/Type/WPObject/SeoObjects.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,46 @@ public static function init(): void {
public static function register(): void {
// Set SEO field types for product children.
$product_types = WP_GraphQL_WooCommerce::get_enabled_product_types();
/**
* @todo: remove this when we don't need to support WooGraphQL< 0.21.1
* @see https://github.com/AxeWP/wp-graphql-rank-math/pull/115#issuecomment-2660900767
*/
if ( defined( 'WPGRAPHQL_WOOCOMMERCE_VERSION' ) && version_compare( WPGRAPHQL_WOOCOMMERCE_VERSION, '0.21.1', '>=' ) ) {
$product_types = array_merge(
$product_types,
[
'DownloadableProduct',
'InventoriedProduct',
'ProductUnion',
'ProductWithAttributes',
'ProductWithDimensions',
'ProductWithPricing',
'ProductWithVariations',
'ProductVariation',
]
);
}

foreach ( $product_types as $graphql_type_name ) {
Utils::overload_graphql_field_type( $graphql_type_name, 'seo', 'RankMathProductObjectSeo' );
}

/**
* @todo: remove this when we don't need to support WooGraphQL< 0.21.1
* @see https://github.com/AxeWP/wp-graphql-rank-math/pull/115#issuecomment-2660900767
*/
if ( defined( 'WPGRAPHQL_WOOCOMMERCE_VERSION' ) && version_compare( WPGRAPHQL_WOOCOMMERCE_VERSION, '0.21.1', '<' ) ) {
self::register_product_variation_types();
}
}

/**
* Registers the SEO types for product variations.
*
* @todo: remove this when we don't need to support WooGraphQL< 0.21.1
* @see https://github.com/AxeWP/wp-graphql-rank-math/pull/115#issuecomment-2660900767
*/
private static function register_product_variation_types(): void {
// Register the Product Variation SEO type and apply it to the Product Variation and children.
$type_name_for_product_variation = 'RankMathProductVariationObjectSeo';

Expand Down
Loading