31 Commits
Author SHA1 Message Date
2ce9424e11 feat: configurable createdVia on order mutations + WooCommerce order attribution (#1018)
* Add option to Change the created_via field.

Can be useful when WooCommerce is being used from multiply sources. For example, with plugins like Point of Sale for WooCommerce.

* feat: createdVia on checkout + WooCommerce order attribution origin

Builds on the createOrder createdVia option:

- Add a createdVia input to the checkout mutation. WC_Checkout::create_order()
  hardcodes created_via to 'checkout' after its data loop, so process_checkout()
  overrides it (and tags the attribution source type) only when createdVia is
  provided; otherwise checkout keeps WooCommerce's 'checkout' default.
- createOrder now defaults created_via to WooCommerce::get_order_attribution_source_type()
  ('graphql-api', filterable) and writes that value to the
  _wc_order_attribution_source_type order meta so GraphQL orders are attributable.
- Register a wc_order_attribution_origin_label callback that brands orders
  attributed to 'graphql-api' as the 'GraphQL' origin in WooCommerce admin.
- Cover createdVia + attribution in OrderMutationsTest and CheckoutMutationTest.

---------

Co-authored-by: Scott Kennedy <scottyzen@gmail.com>
2026-06-12 13:16:53 -04:00
Geoff TaylorandGitHub 460b101b47 fix: HPOS order mutation data loss, COT cursor pagination, email tests, checkout auth (#1003)
* devops: WC email template tests, COT cursor HPOS fix, checkout account auth

WC Email Template Tests:
- Add WooCommerceEmailTemplatesTest verifying WC email templates are used
  for registerCustomer, checkout with account creation, and password reset
- Use MockPHPMailer to capture emails and verify HTML content type
- Disable deferred transactional emails during tests via GRAPHQL_TESTING flag

COT Cursor HPOS Fix:
- Fix COT_Cursor::compare_with to resolve orderby aliases and legacy meta
  keys (_order_total, _date_completed, etc.) to COT column names
- Add resolve_orderby_alias() mapping short aliases and meta keys to columns
- Add DB_Hooks::clean_query_vars to translate post_* and meta_key orderby
  to COT-compatible equivalents via woocommerce_order_query_args filter

Checkout Account Authentication:
- Add authenticate field to CreateAccountInput type
- Gate wc_set_customer_auth_cookie() behind authenticate flag in checkout
  mutation so account creation doesn't auto-authenticate by default

Closes #882

* devops: codeception.dist.yml updated

* fix: Functional test cleanup and CI coverage condition

Test fixes:
- Enable authorizing URL fields in ProtectedRouterCest and
  DownloadableItemAuthCest via setWooGraphQLSetting
- Add stale data cleanup (sessions, users, products, orders) to
  GraphQLE2E _setupStore/getCatalog/setupStoreAndUsers
- Fix CartTransactionQueueCest and CartQueriesTest for test isolation

CI:
- Only run coverage job when at least one upstream job succeeds

* chore: Linter compliances met

* fix: HPOS order mutation data loss and CI coverage condition

Refactor order create/update mutations to set all props on a single
WC_Order instance before saving, mirroring the WC REST API pattern.
Previously, separate add_order_meta() and add_items() calls each loaded
their own order instance and saved independently, causing HPOS data loss
for payment method, addresses, and other fields.

Also fix CI coverage job to only run when all upstream jobs succeed,
and correct test assertions for RAW format line item totals.

Closes #591

* chore: Linter compliances met

* chore: Remove dead code from Order_Mutation after prepare_order refactor

Removes add_items() and update_address() which are no longer called
after the prepare_order() consolidation.

* chore: Remove dead code add_order_meta and update_item_meta_data
2026-03-30 21:42:00 -04:00
5792d76344 Automatically get and set data from the specified product ID (#947)
* always calculate; default quantity of 1

* fill the name; complete order item data

* dont introduce new requirement; leave as is

* fix: auto-fill line item data from product, add format arg to LineItem pricing fields, fix isPaid check (#946)

* devops: upload coverage XML and JSON as debug artifacts after Coveralls push

* chore: Lintercompliances met

---------

Co-authored-by: Geoff Taylor <geoff@axistaylor.com>
2026-03-26 21:29:40 -04:00
Geoff TaylorandGitHub 9dbd9a008a devops: add createOrder stock reduction test (#990)
* devops: add createOrder stock reduction test

Adds test confirming that createOrder with isPaid: true correctly
reduces stock quantity. Tests COD (→ COMPLETED) and BACS (→ PROCESSING)
payment methods, and documents that setting status explicitly alongside
isPaid bypasses WooCommerce's stock reduction hooks. Users should rely
on isPaid alone and let WooCommerce determine the correct order status.

* devops: migrate OrderMutationsTest to factories and add stock reduction test

- Replace deprecated test helper classes with factory equivalents
- Replace wp_set_current_user with loginAsShopManager/loginAsCustomer
- Remove codecept_debug calls (graphql() already logs responses)
- Rename $actual to $response throughout
- Move order creation from setUp to individual tests using createNew()
- Enable woocommerce_manage_stock and payment gateways in setUp
- Add stock reduction test confirming createOrder with isPaid: true
  reduces stock, and documents that setting status explicitly alongside
  isPaid bypasses WooCommerce's stock reduction hooks
2026-03-24 01:56:10 -04:00
Geoff TaylorandGitHub 2d46cbbf9b devops: add updateOrder metaData duplicate order regression test (#983)
Adds test confirming that updateOrder with only metaData input does
not create duplicate orders, covering both new meta creation and
existing meta updates. The issue was likely caused by incorrect ID
resolution via Relay::fromGlobalId() which was fixed in commit
7c10a3d4 (ID resolution made consistent across all mutations).
2026-03-23 18:53:48 -04:00
Geoff TaylorandGitHub f61b55f8df fix: Add direct or/and syntax support to ProductTaxonomyInput and fix test issues (#948)
* fix: Add direct or/and syntax support to ProductTaxonomyInput and fix test issues

* fix: Add OrderNote visibility filters for queries and mutations
2025-10-11 16:29:36 -04:00
Geoff TaylorandGitHub 32f8ba28ca fix: ID resolution made consistent across all edit and delete node mu… (#902)
* fix: ID resolution made consistent across all edit and delete node mutations

* chore: linter compliances met
2024-11-06 15:00:11 -05:00
Geoff TaylorandGitHub ca5dac0abd fix: currency input field fixed for createOrder mutation (#829) 2023-12-27 11:28:24 -05:00
Dovid LevineandGitHub e96236696f chore: bump deps to meet actual requirements and lint for WPCS 3.0 (#816)
* chore: bump min versions to actual and update deps

* chore: fix multiple empty lines at EOF

* chore: preincrement when standalone (phpcs)

* fix: use `printf` instead of `echo sprintf` [phpcs]

* chore: avoid lonely `if()` in `else{}` [phpcs]

* chore: avoid reserved keywords as param names [phpcs]

* chore: remove unused callback params [phpcs]

* chore: remove more unused callback params [phpcs]

* chore: apply lints to tests

* chore: update ruleset for PHPCS 3.0

* texts: restore $last_request_headers
2023-11-30 08:41:32 -05:00
Geoffrey K TaylorandGitHub 9073793e86 chore: WPGraphQL v1.9.x connection resolver support added and autoloader removed. (#647)
* chore: WPGraphQL v1.9x + WP Bedrock support added.

* chore: lint compliance met.

* chore: composer/installers added back to allow-plugins
2022-08-26 14:53:36 -04:00
Geoffrey K TaylorandGitHub 223bde6ea2 feat: "product" and "variation" connections added to LineItem type (#604)
* feat: "product" and "variation" connections added to LineItem type

* chore: Coding standards met

* fix: GraphQLE2E helper updated to reflect schema changes

* chore: PHP 8.0 compliance met

* chore: Workflow codecoverage set to target PHP 7.4

* chore: WPCS compliance met
2022-03-04 23:44:48 -05:00
Geoffrey K TaylorandGitHub 6dbdcb5ae8 fix: Product Attribute naming conventions changed (#603)
* fix: Product Attribute naming conventions changed

* devops: dev dependencies updated

* devops: dev dependencies updated

* devops: dev dependencies updated

* devops: Dockerfile updated

* devops: dev dependencies updated

* devops: dev dependencies updated

* devops: dev dependencies updated

* devops: Dockerfile updated

* chore: Docker composer configurations updated

* chore: Coding standards met.
2022-02-04 15:00:44 -05:00
Geoff Taylor 8215901e93 Order connections refactored. 2021-06-03 21:37:09 -04:00
Geoff TaylorandGeoff Taylor f47bee2b5f Docker/Codeception configuration heavily refactored.. 2021-01-22 11:34:09 -05:00
Geoff Taylor 449d3b1674 "typeId" fields replaced by "databaseId". 2020-09-16 16:32:14 -04:00
Geoff Taylor f14a9478d0 wc-db-loader created 2020-03-20 23:12:04 -04:00
Geoff Taylor b57ec1c34a "DownloadableItem" type and connection implemented. 2020-01-22 03:07:39 -05:00
Geoff Taylor 369fb7aa22 testing updated. 2019-11-13 18:53:31 -05:00
Geoff Taylor 971f4eaf0f ""ProductUnion" type implemented. 2019-10-17 21:39:38 -04:00
Geoff Taylor d6ef041806 "deleteOrderItems" implemented and tested. 2019-07-10 15:21:01 -04:00
Geoff Taylor bb4f5cbd50 "testDeleteOrderMutation" updated 2019-07-05 17:50:27 -04:00
Geoff Taylor 140b64ae04 "deleteOrder" mutation implemented and tested. 2019-07-05 17:27:14 -04:00
Geoff Taylor 02303ec315 "updateOrder" mutation implemented and tested. 2019-07-05 11:59:14 -04:00
Geoff Taylor acf2643c6a "Order_Mutation" class and "Order_Create" class refactor complete."
;
2019-07-04 14:11:06 -04:00
Geoff Taylor 1b16268c37 Heavy refactoring done to Order_Mutation class 2019-07-04 01:49:01 -04:00
Geoff Taylor fccf7b98dd Placemarker before Order_Mutation refactor 2019-07-03 18:25:18 -04:00
Geoff Taylor 7086a456f0 New input types implemented 2019-07-01 22:51:49 -04:00
Geoff Taylor 5e381c35d3 initial commit 2019-07-01 16:29:16 -04:00
Geoff Taylor 4e4654c540 CouponQueriesTest refactored. Unneeded tests removed. 2019-04-13 00:46:16 -04:00
Geoff Taylor 9949927b2b clean-up started 2019-03-21 21:43:24 -04:00
Geoff Taylor 0db77c26ab initial commit 2019-03-13 12:31:37 -04:00