Skip to content

Commit cf0b6c8

Browse files
committed
add checkoutShippingLineUpdateMutation
1 parent 3e5d929 commit cf0b6c8

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Diff for: src/checkout-resource.js

+15
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import checkoutGiftCardsAppendMutation from './graphql/checkoutGiftCardsAppendMu
1717
import checkoutGiftCardRemoveV2Mutation from './graphql/checkoutGiftCardRemoveV2Mutation.graphql';
1818
import checkoutEmailUpdateV2Mutation from './graphql/checkoutEmailUpdateV2Mutation.graphql';
1919
import checkoutShippingAddressUpdateV2Mutation from './graphql/checkoutShippingAddressUpdateV2Mutation.graphql';
20+
import checkoutShippingLineUpdateMutation from './graphql/checkoutShippingLineUpdateMutation.graphql';
2021

2122
/**
2223
* The JS Buy SDK checkout resource
@@ -333,6 +334,20 @@ class CheckoutResource extends Resource {
333334
.send(checkoutShippingAddressUpdateV2Mutation, {checkoutId, shippingAddress})
334335
.then(handleCheckoutMutation('checkoutShippingAddressUpdateV2', this.graphQLClient));
335336
}
337+
338+
/**
339+
* Updates the shipping lines on an existing checkout.
340+
*
341+
* @param {String} checkoutId The ID of the checkout to update shipping address.
342+
* @param {Object} shippingRateHandle A unique identifier to a Checkout’s shipping provide
343+
* @return {Promise|GraphModel} A promise resolving with the updated checkout.
344+
*/
345+
updateShippingLineAddress(checkoutId, shippingRateHandle) {
346+
return this.graphQLClient
347+
.send(checkoutShippingLineUpdateMutation, {checkoutId, shippingRateHandle})
348+
.then(handleCheckoutMutation('checkoutShippingLineUpdate', this.graphQLClient));
349+
}
350+
336351
}
337352

338353
export default CheckoutResource;
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
mutation checkoutShippingLineUpdate($checkoutId: ID!, $shippingRateHandle: String!) {
2+
checkoutShippingLineUpdate(
3+
checkoutId: $checkoutId
4+
shippingRateHandle: $shippingRateHandle
5+
) {
6+
checkout {
7+
id
8+
}
9+
checkoutUserErrors {
10+
code
11+
field
12+
message
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)