Files
wp-graphql-woocommerce/includes
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
..