Closed felipepxavier closed 2 years ago
@felipepxavier See this :point_right: https://github.com/wp-graphql/wp-graphql-woocommerce/pull/182
Hi, @kidunot89 , any suggestion?
using mutation: mutation ($input: UpdateShippingMethodInput!) { updateShippingMethod(input: $input) { clientMutationId cart { availableShippingMethods { packageDetails supportsShippingCalculator rates { id cost label } } chosenShippingMethod } } }
result:
message: Field "cart" is not defined by type UpdateShippingMethodInput."
{ "input":{ "clientMutationId": "dfgdfd", "cart": { "availableShippingMethods":{ "rates":{ "id": "66", "cost": "25.75", "label": "Method Test" } }, "chosenShippingMethod": "66" } } }
@felipepxavier I'm sorry the example in the PR summary had an error and I've fixed it. Please try the updated mutation.
To clarify what changed the cart
should be customer
.
Also make sure you're using WooCommerce Session tokens. Read more about that [here] (https://github.com/wp-graphql/wp-graphql-woocommerce/pull/88)
@kidunot89 hello! thanks for the feedback!
But in the documentation the mutation "UpdateShippingMethodPayload" accepts:
cart: Cart
clientMutationId: String!
However using "cart", it presents this message: "Field 'cart' is not defined by type UpdateShippingMethodInput. "
And replacing cart for customer shows this message: "Cannot query field 'customer' on type UpdateShippingMethodPayload "..
@felipepxavier your input is incorrect. Look up the UpdateShippingMethodInput
type in the docs. You should only have to pass the rateId to set the shipping method.
@kidunot89 so i'm using the wrong mutation, i wanted to create a "shipping method" and apply it to the request, because i have an API that returns me several shipping method, so i wanted to link only the method that the user selects ..
@kidunot89 confirm me one thing, we were unable to create shipping methods, but "select" the existing woocomerce native methods and "link" them in orders, this?
Yea, if you wish to create a shipping method, you have to do it through WooCommerce admin or code. WooGraphQL doesn't provide that capability, but you can use any shipping method made available through WooCommerce Shipping Method API
@kidunot89 I understand, but how does the shipping method identify the zip code to show shipping options? Is there a "query" that receives a zip code to consult?
query GetShippingMethods { shippingMethods {
nodes {
title
methodId
id
description
}
} }
@kidunot89 this query shows the options, but I still haven't figured out how to view the value of each option in this list, or if it's possible.
@felipepxavier Use the Documentation Explorer
in the GraphQL IDE to look up the updateCustomer()
mutation. The availableShippingMethods
field uses the zip code set in the session customer's shipping address. You have to be using the session token for it to work.
@felipepxavier Any updates on this?
Hi, @kidunot89 ! I had to interrupt this project, so when I return I will give feedback here .. thanks!
@felipepxavier Were you able to get the mutation working?
Hello, I would like to know how to apply the value of the "shipping metrod", it seems to me to receive only one String, how to insert a value together in the mutation checkout? thankss