feat: persist shipping phone through the checkout mutation (#1017)

* feat: persist shipping phone through the checkout mutation

The shipping fieldset in Checkout_Mutation::get_checkout_fields() omitted
the phone field, so a phone passed in the checkout mutation's shipping
input was never mapped into shipping_phone and WC_Order::set_shipping_phone()
was never called. Add phone to the shipping fieldset so it flows through to
the order, matching the billing fieldset.

Closes #1016

* fix: load QL session handler when a session token header is present

should_load_session_handler() only matched explicit wc-ajax / WC_DOING_AJAX
and REST_REQUEST contexts. Headless callers drive session state through the
Store-API Cart-Token header or the legacy woocommerce-session header and can
land on other admin-ajax/REST entrypoints, leaving the session bootstrapped
from an absent cookie. Detect either session header and also honor
wp_doing_ajax() so QL_Session_Handler loads and rebuilds the session from the
token.

* ci: authenticate composer GitHub access to fix flaky strauss install

The dependency-install steps run with the github-oauth token that composer
rejects ("contains invalid characters"), so composer and strauss's internal
composer bootstrap fall back to unauthenticated GitHub access. Under the
shared runner IP's 60/hr unauthenticated rate limit, strauss intermittently
exits 1 during post-install-cmd, failing lint, PHPStan, wpunit, functional
and acceptance jobs at random.

Provide a well-formed COMPOSER_AUTH built from the always-available
GITHUB_TOKEN on every dependency-install step so GitHub API access is
authenticated (5000/hr), removing the flake.

* ci: run strauss with a clean composer auth context

setup-php writes the runner's GITHUB_TOKEN into composer's global auth.json,
and this composer rejects that token format ("github oauth token contains
invalid characters"). strauss spins up its own internal Composer instance,
which reads that auth, hits the validation error and exits 1 with no output,
failing every job at the post-install/post-update strauss step.

strauss only rewrites local vendor packages and needs no GitHub auth, so run
it with COMPOSER_AUTH unset and a throwaway COMPOSER_HOME. Fixes all CI
install steps, local installs and release packaging from one place.

This reverts the earlier per-workflow COMPOSER_AUTH attempt, which could not
work because composer rejects the token regardless of how it is supplied.

* style: align equals sign in should_load_session_handler (phpcs)
This commit is contained in:
Geoff Taylor
2026-06-11 20:02:26 -04:00
committed by GitHub
parent e82ace934c
commit 01876f5344
4 changed files with 68 additions and 3 deletions
+42
View File
@@ -133,6 +133,7 @@ class CheckoutMutationTest extends \Tests\WPGraphQL\WooCommerce\TestCase\WooGrap
state
postcode
country
phone
}
paymentMethod
paymentMethodTitle
@@ -293,6 +294,7 @@ class CheckoutMutationTest extends \Tests\WPGraphQL\WooCommerce\TestCase\WooGrap
'state' => 'NY',
'postcode' => '12345',
'country' => 'US',
'phone' => '555-555-6789',
],
'metaData' => [
[
@@ -446,6 +448,8 @@ class CheckoutMutationTest extends \Tests\WPGraphQL\WooCommerce\TestCase\WooGrap
'checkout.customer.id',
$this->toRelayId( 'user', $this->customer )
),
$this->expectedField( 'checkout.order.billing.phone', '555-555-1234' ),
$this->expectedField( 'checkout.order.shipping.phone', '555-555-6789' ),
$this->expectedField( 'checkout.result', 'success' ),
$this->expectedField( 'checkout.redirect', static::NOT_NULL ),
];
@@ -463,6 +467,44 @@ class CheckoutMutationTest extends \Tests\WPGraphQL\WooCommerce\TestCase\WooGrap
$this->assertQuerySuccessful( $response, $expected );
}
public function testCheckoutMutationPersistsShippingPhone() {
$this->loginAsCustomer();
$product_id = $this->factory->product->createSimple();
WC()->cart->add_to_cart( $product_id, 1 );
$input = [
'shipping' => [
'firstName' => 'May',
'lastName' => 'Parker',
'address1' => '20 Ingram St',
'city' => 'New York City',
'state' => 'NY',
'postcode' => '12345',
'country' => 'US',
'phone' => '555-555-6789',
],
];
$variables = [ 'input' => $this->getCheckoutInput( $input ) ];
$query = $this->getCheckoutMutation();
$response = $this->graphql( compact( 'query', 'variables' ) );
// The shipping phone is returned on the order and is distinct from the billing phone.
$this->assertQuerySuccessful(
$response,
[
$this->expectedField( 'checkout.order.billing.phone', '555-555-1234' ),
$this->expectedField( 'checkout.order.shipping.phone', '555-555-6789' ),
]
);
// And it is saved on the underlying WC_Order object.
$order_id = $response['data']['checkout']['order']['databaseId'];
$order = \wc_get_order( $order_id );
$this->assertEquals( '555-555-6789', $order->get_shipping_phone() );
}
public function testCheckoutMutationWithNewAccount() {
$variable = $this->factory->product_variation->createSome();
$product_ids = [