Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
$customerAddressId = $shippingAddressInput['customer_address_id'] ?? null;
$addressInput = $shippingAddressInput['address'] ?? null;

if ($addressInput) {
$addressInput['customer_notes'] = $shippingAddressInput['customer_notes'] ?? '';
}

if (null === $customerAddressId && null === $addressInput) {
throw new GraphQlInputException(
__('The shipping address must contain either "customer_address_id" or "address".')
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/QuoteGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ input SetShippingAddressesOnCartInput {
input ShippingAddressInput {
customer_address_id: Int # If provided then will be used address from address book
address: CartAddressInput
customer_notes: String
}

input SetBillingAddressOnCartInput {
Expand Down Expand Up @@ -210,17 +211,18 @@ interface CartAddressInterface @typeResolver(class: "\\Magento\\QuoteGraphQl\\Mo
postcode: String
country: CartAddressCountry
telephone: String
customer_notes: String
}

type ShippingCartAddress implements CartAddressInterface {
available_shipping_methods: [AvailableShippingMethod] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\AvailableShippingMethods")
selected_shipping_method: SelectedShippingMethod @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\SelectedShippingMethod")
items_weight: Float
cart_items: [CartItemQuantity]
customer_notes: String
}

type BillingCartAddress implements CartAddressInterface {
customer_notes: String @deprecated (reason: "The field is used only in shipping address")
}

type CartItemQuantity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
telephone: "88776655"
save_in_address_book: false
}
customer_notes: "Test note"
}
]
}
Expand All @@ -102,6 +103,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
code
}
__typename
customer_notes
}
}
}
Expand Down Expand Up @@ -671,7 +673,8 @@ private function assertNewShippingAddressFields(array $shippingAddressResponse):
['response_field' => 'postcode', 'expected_value' => '887766'],
['response_field' => 'telephone', 'expected_value' => '88776655'],
['response_field' => 'country', 'expected_value' => ['code' => 'US', 'label' => 'US']],
['response_field' => '__typename', 'expected_value' => 'ShippingCartAddress']
['response_field' => '__typename', 'expected_value' => 'ShippingCartAddress'],
['response_field' => 'customer_notes', 'expected_value' => 'Test note']
];

$this->assertResponseFields($shippingAddressResponse, $assertionMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
telephone: "88776655"
save_in_address_book: false
}
customer_notes: "Test note"
}
]
}
Expand All @@ -73,6 +74,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
label
}
__typename
customer_notes
}
}
}
Expand Down Expand Up @@ -527,7 +529,8 @@ private function assertNewShippingAddressFields(array $shippingAddressResponse):
['response_field' => 'postcode', 'expected_value' => '887766'],
['response_field' => 'telephone', 'expected_value' => '88776655'],
['response_field' => 'country', 'expected_value' => ['code' => 'US', 'label' => 'US']],
['response_field' => '__typename', 'expected_value' => 'ShippingCartAddress']
['response_field' => '__typename', 'expected_value' => 'ShippingCartAddress'],
['response_field' => 'customer_notes', 'expected_value' => 'Test note']
];

$this->assertResponseFields($shippingAddressResponse, $assertionMap);
Expand Down