wp-graphql/wp-graphql-woocommerce
Composer 安装命令:
composer require wp-graphql/wp-graphql-woocommerce
包简介
WooCommerce bindings for WPGraphQL
关键字:
README 文档
README
WPGraphQL for eCommerce
Website • Docs • Schema • Playground • About • Join Slack
Install
Installing Manually
- Install and activate WPGraphQL and WooCommerce.
- Download the
wp-graphql-woocommerce.zipfile from the Assets section of the most stable release and activate the plugin in your WordPress directory. - Set your GraphQL client endpoint to your site's GraphQL endpoint. Typically, this is
your-store.domain/graphql.
Installing with Composer
This method is recommended for users with unique installations like WP Bedrock or SpinupWP.
- Install WordPress and WooCommerce.
- Install WPGraphQL and WPGraphQL for WooCommerce by running
composer require wp-graphql/wp-graphql wp-graphql/wp-graphql-woocommerce. - Set your GraphQL client endpoint to your site's GraphQL endpoint. For typical Bedrock or SpinupWP setups, the default will be
your-store.domain/wp/graphql.
Optional Extras
- Install & activate WPGraphQL-JWT-Authentication to introduce a
loginmutation that returns a JSON Web Token. - Install & activate WPGraphQL Headless Login to introduce a
loginmutation with OAuth2 client support. Shouldn't be used with WPGraphQL-JWT-Authentication - Install & activate WPGraphQL-CORS for enhanced security via HTTP CORS and to utilize some advanced WPGraphQL features.
What Can You Do with This Extension?
- Query your shop's products and variations with detailed filtering options.
- Query customers, orders, coupons, and refunds. Note: Operations have user restrictions.
- Create and delete refunds on orders.
- Manage customer sessions using JWTs or WooCommerce Store API Cart-Tokens, and use cart/customer queries and mutations. Note: Operations have user restrictions.
- Manually create orders, automate order creation with the checkout mutation, or delegate a customer's session to the WooCommerce checkout page in your theme for comprehensive payment gateway support.
- Query and update WooCommerce settings via the GraphQL API.
(*) These operations have user restrictions. Learn how to utilize them correctly at the resources listed below:
- Authentication and Authorization
- Configuring a GraphQL Client for WooCommerce User Session Management
- Handling User Authentication
- Handling User Session and Using Cart Mutations
- Using Checkout Mutation and Order Mutations
- Using Order Data
(#) The recommended method to checkout, taking full advantage of WooCommerce's payment gateways for payment process and other checkout-related extenstions, is to pass the session back to the WordPress installation and let WooCommerce take over from the tradition checkout page. Learn more about this approach below.
Alternatively, you can create a custom checkout form and process payments externally. Here is some resources for that as well.
Why Don't WooCommerce CPT GraphQL Types Support All the Features WPGraphQL Exposes for Most WordPress CPTs?
WooCommerce's Custom Post Types (CPTs) and most data objects are managed by a data store system. This system allows for flexible data object definitions. While objects like products, orders, and coupons are defined as WordPress CPTs by default, they don't have to be.
This flexibility also lets WooCommerce store metadata for these CPTs in separate tables, and the data doesn't necessarily have to reside in the same database.
The data store system and its object managers are WooGraphQL's primary contact points. Unlike standard CPTs, which use a WP_Post object for data sourcing and a WPGraphQL\Model\Post object for modeling, WPGraphQL for WooCommerce engages object managers for its data source. Each object type has a unique model with distinct permissions and restrictions.
Such a setup has resulted in some disparities between the schema where WPGraphQL for WooCommerce support might be lacking. We apologize for any inconvenience. Both I and the entire WPGraphQL team are actively working to harmonize WPGraphQL for WooCommerce with all WPGraphQL and WPGraphQL ACF features.
Thank you for your patience 😄 @kidunot89
For WooCommerce Extensions Support
WooGraphQL Pro is an extension of WPGraphQL for WooCommerce that provides compatibility with a variety of popular WooCommerce extensions. This compatibility empowers you to leverage these extensions within the context of the GraphQL API, thereby enabling you to build more dynamic and powerful headless eCommerce applications.
The following WooCommerce extensions are supported by WooGraphQL Pro:
- WooCommerce Subscriptions
- WooCommerce Product Bundles
- WooCommerce Product Add-Ons
- WooCommerce Composite Products
Installing Supported WooCommerce Extensions (Optional)
If you wish to use any of the supported WooCommerce extensions with WooGraphQL Pro, follow these steps:
- Purchase your desired extensions from the WooCommerce marketplace. The supported extensions are listed above.
- Download the
.zipfile(s) for your purchased extension(s) from your WooCommerce account. - In your WordPress Admin Dashboard, navigate to Plugins > Add New > Upload Plugin, and upload the downloaded
.zipfile(s). - Once the upload is complete, click on 'Activate Plugin' to activate the extension(s).
Installing and Activating WooGraphQL Pro
To install and activate WooGraphQL Pro, follow these steps:
- Purchase WooGraphQL Pro from our official website.
- After purchase you should find yourself on your account dashboard. Go to the
Licensespage and generate and new license and copy it for later. - Next go to the
Downloadspage and download the latest version of WooGraphQL Pro. - Go to your WordPress Admin Dashboard, navigate to Plugins > Add New > Upload Plugin, and upload the
woographql-pro.zipfile you downloaded. - After uploading, click 'Activate Plugin' to activate WooGraphQL Pro.
Enabling Schema Support for Installed Extensions
To enable schema support for your installed extensions, follow these steps:
- Navigate to the WPGraphQL settings page on your WordPress Admin Dashboard.
- Click on the 'WooGraphQL' tab.
- Here, you'll find a list of WPGraphQL for WooCommerce configuration options. Go below to the WooGraphQL Pro section and paste in license and check the boxes next to your installed extensions to enable schema support for them.
Note: The 'Enable Unsupported Product Type' option can be found on the same settings tab. If you enable this option, any product type without a proper GraphQL type will default to the UnsupportedProduct type, which is identical to the SimpleProduct type. With this type, the client can use the metaData field to get a string representation of the meta data on the type. This could potentially be all that's needed for simpler product types.
With WooGraphQL Pro and your chosen extensions now installed, you're ready to build more sophisticated, feature-rich eCommerce solutions with WordPress and WooCommerce.
Development Tools
Playground
Feel free to test out the extension using this GraphiQL Playground. The playground allows you to execute queries and mutations, as well as view the schema (*).
(*) I have a tendency to forget to update the playground between releases 😅, so if you believe this to be the case look me up somewhere on this page and lemme know 🤷♂️
create-woonext-app CLI and @woographql packages
Designed to both streamline development for individuals and teams looking to utilize WooCommerce + WooCommerce extensions in larger project and not waste too much to much time on the particulars of WPGraphQL for WooCommerce like session management or checkout, the create-woonext-app CLI generates a pre-created e-commerce application on Next.js application tailored to the developer/team.
npx create-woonext-app <license> [options]
The generated application utilizes the @woographql packages exclusive to the unlimited/annual subscribers of WooGraphQL Pro. So Go Subscribe! 😄. Below are more resources on the create-woonext-app CLI and @woographql packages.
create-woonext-appHomepagecreate-woonext-appon NPM: Thecreate-woonext-appREADME with more CLI usage instructions.create-woonext-appLive Demo: fully decked out putting all current possible functionalities of thecreate-woonext-appon full display.@woographql/nextREADME: A Template generator CLI. Capable of generator a multitude of Next.js pages, Next.js Route Handlers, react components, react hooks, and utilities. It's also equipped to generate react component and hook stubs for speedy component create with no boilerplate.@woographql/react-hooksREADME: React hook library acting as the backbone for UI connected to session, cart, and customer.@woographql/session-utilsREADME: Provides utilities for managing the WPGraphQL + WPGraphQL for WooCommerce session tokens like aTokenManager, also provides interfaces and types for easy customization of saidTokenManageror the complete creation of a customTokenManagerwith minimal effort. The bundled TokenManager implemented utilizes browser storage (Local/Session storage), so if you'd prefer something like Iron Session this might be the route for you.@woographql/codegenREADME: A convenient wrapper for GraphQL Codegen providing a few configurations out of the box, with the ability to override the default configuration by creating acodegen.tsin the project root.
Wanna help support WooGraphQL's future
- Sponsor @kidunot89 (WPGraphQL for WooCommerce Creator/Developer) on Github
- Sponsor WooGraphQL on OpenCollective
- Sponsor WPGraphQL on OpenCollective
- Sponsor GraphQL-PHP on OpenCollective
- Or Contribute
Follow 

Demo/Examples
- Examples with Next.js
- Examples with Gatsby
- Examples with WooGraphQL Pro [homepage]
Who using it?
| Rocky Mountain Sewing & Vacuum | Russemerket | wohnparc.de |
Contributors
Code Contributors
This project exists thanks to all the people who contribute. [Contribute].
Financial Contributors
Become a financial contributor and help us sustain our community. [Contribute]
Individuals
Organizations
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]
Disclaimer: WPGraphQL for WooCommerce is an open-source WordPress plugin and WooCommerce extension developed and maintained by Geoff Taylor, licensed under GPLv3. It is not owned, maintained, or affiliated with Automattic or WooCommerce.
wp-graphql/wp-graphql-woocommerce 适用场景与选型建议
wp-graphql/wp-graphql-woocommerce 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 56.51k 次下载、GitHub Stars 达 700, 最近一次更新时间为 2019 年 12 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「wordpress」 「woocommerce」 「graphql」 「wp-graphql」 「wp-graphql-extension」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wp-graphql/wp-graphql-woocommerce 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wp-graphql/wp-graphql-woocommerce 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wp-graphql/wp-graphql-woocommerce 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Paytrail is a payment gateway that offers 20+ payment methods for Finnish customers.
WooCommerce Rest API with Laravel
The Web Solver License Manager Server
WooCommerce Rest API for PHP
A PHP Wrapper for handling REST API for License Manager for WooCommerce
统计信息
- 总下载量: 56.51k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 701
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2019-12-23