Skip to content
Adds Woocommerce functionality to a WPGraphQL schema
Branch: develop
Clone or download
Latest commit de0b0f0 Jul 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Mar 16, 2019
bin "slug" and "sku" arguments added to "productBy" query. Jul 10, 2019
includes Session header bugfix Jul 18, 2019
tests "updateItemQuantity" mutation refactored to "updateItemQuantities" mu… Jul 11, 2019
vendor "Actions" and "Filters" classes renamed and refactored. Jul 11, 2019
.coveralls.yml Integration configuration files updated Apr 6, 2019
.distignore initial commit Mar 13, 2019
.editorconfig initial commit Mar 13, 2019
.env.dist Comments removed from ".env.dist". "composer install" statement modif… May 30, 2019
.gitignore Composer.lock deleted. Version specification removed for some packages. May 31, 2019
.phpcs.ruleset.xml migration complete and wpcs standardsmet Mar 26, 2019
.travis.yml .travis.yml updated. Jul 1, 2019
CHANGELOG.md CHANGELOG.md and README.md updated. Jul 11, 2019
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Mar 16, 2019
CONTRIBUTING.md PULL_REQUEST_TEMPLATE.md & CONTRIBUTING.md created Mar 16, 2019
LICENSE Update LICENSE Apr 11, 2019
PULL_REQUEST_TEMPLATE.md .travis.yml updated Mar 16, 2019
README.md CHANGELOG.md and README.md updated. Jul 11, 2019
README.txt README files updated Mar 15, 2019
access-functions.php Variable-type product formatting added. Jun 2, 2019
class-inflect.php Placemarker before Order_Mutation refactor Jul 3, 2019
codeception.yml
composer.json initial commit Jun 24, 2019
logo.svg spacing and docblocks fixed Mar 22, 2019
phpunit.xml.dist initial commit Mar 13, 2019
wp-graphql-woocommerce.php Plugin version updated. Jul 15, 2019

README.md

WPGraphQL WooCommerce

Build Status Coverage Status

Quick Install

  1. Install & activate WooCommerce
  2. Install & activate WPGraphQL
  3. (Optional) Install & activate WPGraphQL-JWT-Authentication to add a login mutation that returns a JSON Web Token.
  4. Clone or download the zip of this repository into your WordPress plugin directory & activate the WP GraphQL WooCommerce plugin

What does this plugin do?

It adds WooCommerce functionality to the WPGraphQL schema using WooCommerce's CRUD objects.

Working Features

  • Query product, customers, coupons, order, refund, product variations.

Upcoming Features

  • Adminstrator mutations. Eg. Creating and deleting products, coupons, and refunds.

Playground

Feel free to test out the extension using the playground. The playground allows you to execute queries and mutations, as well as view the schema.

Unit Tests

Until the documentation is in full effect, it's recommended that a GraphiQL-based tool like WPGraphiQL be used to view the GraphQL schema, an alternative to this is viewing the unit tests located in tests/wpunit directory. Which are constantly updated along with the project. If you're interested in contributing when I begin accepting contribution or simply want to run the tests. Follow the instruction below.

Prerequisties

Setup

  1. Make sure all dependencies are install by running composer install from the CMD/Terminal in the project directory.

  2. Next the copy 5 distributed files with the .dist in there filenames. For instance .env.dist becomes .env and wpunit.suite.dist.yml becomes wpunit.suite.yml. The distributed files and what their copied names should are as follows.

    • tests/acceptance.suite.dist.yml => tests/acceptance.suite.yml
    • tests/functional.suite.dist.yml => tests/functional.suite.yml
    • tests/wpunit.suite.dist.yml => tests/wpunit.suite.yml
    • codeception.dist.yml => codeception.yml
    • .env.dist => .env
  3. Next open .env and alter to make you usage.

    # Shared
    TEST_DB_NAME="wpgraphql_woocommerce_test"
    TEST_DB_HOST="127.0.0.1"
    TEST_DB_USER="root"
    TEST_DB_PASSWORD=""
    
    # Install script
    WP_VERSION=latest
    SKIP_DB_CREATE=false
    WP_GRAPHQL_BRANCH=develop
    
    # Codeception
    WP_ROOT_FOLDER="/tmp/wordpress"
    TEST_SITE_WP_ADMIN_PATH="/wp-admin"
    TEST_SITE_DB_NAME="wpgraphql_woocommerce_test"
    TEST_SITE_DB_HOST="127.0.0.1"
    TEST_SITE_DB_USER="root"
    TEST_SITE_DB_PASSWORD=""
    TEST_SITE_TABLE_PREFIX="wp_"
    TEST_TABLE_PREFIX="wp_"
    TEST_SITE_WP_URL="http://wp.test"
    TEST_SITE_WP_DOMAIN="wp.test"
    TEST_SITE_ADMIN_EMAIL="admin@wp.test"
    TEST_SITE_ADMIN_USERNAME="admin"
    TEST_SITE_ADMIN_PASSWORD="password"
    
    • Shared variables are as the comment implies, variables shared in both the install-wp-tests script and the Codeception configuration. The variable names should tell you what they mean.
    • Install script variables are specified to the install-wp-tests script, and most likely won't changed. I've listed their meaning below.
      • WP_VERSION WordPress version used for testing
      • SKIP_DB_CREATE Should database creation be skipped?
      • WP_GRAPHQL_BRANCH The branch in the WPGraphQL repository the tests should be run again. Ex. origin/feature/model-layer
    • Codeception variables are specified to the Codeception configuration. View the config files and Codeception's Docs for more info on them.
  4. Once you have finish modifying the .env file. Run composer install-wp-tests from the project directory.

  5. Upon success you can begin running the tests.

Running tests

To run test use the command vendor/bin/codecept run [suite [test [:test-function]]]. If you use the command with at least a suite specified, Codeception will run all tests, however this is not recommended. Running a suite vendor/bin/codecept run wpunit or a test vendor/bin/codecept run CouponQueriesTest is recommended. Running a single test-function like vendor/bin/codecept run ProductQueriesTest:testProductsQueryAndWhereArgs is also possible.

To learn more about the usage of Codeception with WordPress view the Documentation

HTTP Error 500 🚧

If you get HTTP 500 error upon activation or accessing the endpoint and have CMD/Terminal access with Composer installed.

  • Try deleting the vendor directory rm -rf vendor and regenerating the autoloading files composer dumpautoload -o in the wp-graphql-woocommerce directory in your WordPress installation's plugins directory.
  • (Alternative) You can also try delete and cloning the repository again. The latest release should have fixed the issue.

Support this extension

WPGraphQL 👉 OpenCollective

GraphQL-PHP 👉 OpenCollective

Follow

alt text alt text

You can’t perform that action at this time.