Code Monkey home page Code Monkey logo

wp-graphql-woocommerce's Introduction

WPGraphQL WooCommerce (WooGraphQL) Logo

WPGraphQL WooCommerce (WooGraphQL)

WebsiteDocsAxisTaylor • Join Slack

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

Install

Installing manually

  1. Install and activate WPGraphQL and WooCommerce
  2. Download wp-graphql-woocommerce.zip file under the Assets section for the most stable release from the repository into your WordPress plugin directory & activate the plugin.
  3. Set your GraphQL client endpoint to the GraphQL endpoint of your site. Typically, this is your-store.domain/graphql.

Installing w/ Composer

This is the recommend way for users using unique installations like WP Bedrock or SpinupWP.

  1. Install WordPress and WooCommerce.
  2. Install WPGraphQL and WooGraphQL by running composer require wp-graphql/wp-graphql wp-graphql/wp-graphql-woocommerce
  3. Set your GraphQL client endpoint to the GraphQL endpoint of your site. Typically, this is your-store.domain/graphql. _NOTE: for typically Bedrock or SpinupWP setups it'll be your-store.domain/wp/graphql by default.

Optional extras

  • Install & activate WPGraphQL-JWT-Authentication to add a login mutation that returns a JSON Web Token.
  • 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:

For WooCommerce Extensions Support

WooGraphQL Pro is an advanced version of WooGraphQL 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:

  1. Purchase your desired extensions from the WooCommerce marketplace. The supported extensions are listed above.
  2. Download the .zip file(s) for your purchased extension(s) from your WooCommerce account.
  3. In your WordPress Admin Dashboard, navigate to Plugins > Add New > Upload Plugin, and upload the downloaded .zip file(s).
  4. 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:

  1. Purchase WooGraphQL Pro from our official website.
  2. After purchase you should find yourself on your account dashboard. Go to the Licenses page and generate and new license and copy it for later.
  3. Next go to the Downloads page and download the latest version of WooGraphQL Pro.
  4. Go to your WordPress Admin Dashboard, navigate to Plugins > Add New > Upload Plugin, and upload the woographql-pro.zip file you downloaded.
  5. 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:

  1. Navigate to the WPGraphQL settings page on your WordPress Admin Dashboard.
  2. Click on the 'WooGraphQL' tab.
  3. Here, you'll find a list of WooGraphQL 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.

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 🤷‍♂️

Wanna help support WooGraphQL's future

Follow alt textalt text

Demo/Examples

Who using WooGraphQL

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]

wp-graphql-woocommerce's People

Contributors

kidunot89 avatar jacobarriola avatar justlevine avatar creative-andrew avatar jasonbahl avatar davevanhoorn avatar hwsiew avatar fabiojundev avatar victormattosvm avatar oskarmodig avatar hilmerx avatar monkeywithacupcake avatar craigwilcox avatar ardiewen avatar krystianjj avatar lstellway avatar matthijs166 avatar saleebm avatar renatonascalves avatar ramyareye avatar sbolinger-godaddy avatar scottyzen avatar adrienpicard avatar believelody avatar manuelsampl avatar namli avatar ranaaterning avatar kpoelhekke avatar khlieng avatar jmotes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.