• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

wp-graphql/wp-graphql-woocommerce: Add WooCommerce support and functionality to ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

wp-graphql/wp-graphql-woocommerce

开源软件地址(OpenSource Url):

https://github.com/wp-graphql/wp-graphql-woocommerce

开源编程语言(OpenSource Language):

PHP 98.7%

开源软件介绍(OpenSource Introduction):

WPGraphQL WooCommerce (WooGraphQL)

DocsAxisTaylor • Join Slack

Automated-Testing Coding-Standards Coverage Status Financial Contributors on Open Collective

Quick Install

  1. Install & activate WooCommerce
  2. Install & activate WPGraphQL
  3. Download the latest release from here or Clone / download the zip of this repository into your WordPress plugin directory, run composer install in plugin directory & activate the WP GraphQL WooCommerce plugin.
  4. (Optional) Install & activate WPGraphQL-JWT-Authentication to add a login mutation that returns a JSON Web Token.
  5. (Optional) Install & activate WPGraphQL-CORS to add an extra layer of security using HTTP CORS and some of WPGraphQL advanced functionality.

What can you do with this extension?

  • Query your shops products and variations with complex filtering options.
  • Query customers, orders, coupons, and refunds (*).
  • Manage a customer's session with JWTs and cart/customer queries and mutations(*).
  • Create orders manually (*), automatically with the checkout mutation, or pass a customer's session to the WooCommerce checkout page in your theme for complete payment gateway support (#).

(*) These operations have user restrictions. Please read up on authenticating an user with here, then view this React/Apollo example with the added on usage of customer session Token.

(#) This is the recommended method on checkout. You can read it's usage in this excellent write-up by @jacobarriola

Why don't the WooCommerce CPT GraphQL types support all the same features as most WordPress CPTs that WPGraphQL exposes?

The CPTs as well as most of the data objects that WooCommerce defines are wrapped in a object managers distributed by a data store system.

This data store system allows for each individual data object to be defined however needed. What this means is, although by out of the box objects like products, orders, and coupons are defined as WordPress CPTs they don't have to be.

This is what also enables WooCommerce to store most meta connected to these CPTs in separate tables. The object data doesn't even have to be in the same database if the object's data store designed to manage somewhere else, but we are getting out of the scope of this question.

What does all this ☝️ have to do with WooCommerce's CPTs' functionality? Well, the object managers distributed by the data store are WooGraphQL first point of contact for pretty much everything. Unlike the most common CPTs which use a WP_Post object as their data source and a WPGraphQL\Model\Post object as their model, WooGraphQL uses object managers as the data source for the CPTs and each individual has it's own model with it's own set of permissions and restrictions.

This has led to some friction is certain areas of the schema where WooGraphQL support is lacking. I'm sorry for the inconvience, myself and whole WPGraphQL org are working to reduce this friction and WooGraphQL properly integrated with all WPGraphQL + WPGraphQL ACF features.

Thank you for your patience @kidunot89

Future Features

  • Product CRUD mutations.
  • And some other stuff I'm sure :thinking_face:

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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap