Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shipping metrod [checkout mutation] #334

Closed
felipepxavier opened this issue Aug 30, 2020 · 14 comments
Closed

Shipping metrod [checkout mutation] #334

felipepxavier opened this issue Aug 30, 2020 · 14 comments
Labels
question Further information is requested

Comments

@felipepxavier
Copy link

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

'shippingMethod' => array (
'type' => 'String',
'description' => __ ('Order shipping method', 'wp-graphql-woocommerce'),
@kidunot89
Copy link
Member

@felipepxavier See this 👉 #182

@kidunot89 kidunot89 added the question Further information is requested label Aug 31, 2020
@felipepxavier
Copy link
Author

felipepxavier commented Sep 6, 2020

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"
}
}
}

@kidunot89
Copy link
Member

kidunot89 commented Sep 9, 2020

@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] (#88)

@felipepxavier
Copy link
Author

felipepxavier commented Sep 10, 2020

@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 "..

@kidunot89
Copy link
Member

kidunot89 commented Sep 10, 2020

@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.

@felipepxavier
Copy link
Author

@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 ..

@felipepxavier
Copy link
Author

@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?

@kidunot89
Copy link
Member

kidunot89 commented Sep 10, 2020

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

@felipepxavier
Copy link
Author

@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?

@felipepxavier
Copy link
Author

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.

@kidunot89
Copy link
Member

kidunot89 commented Oct 15, 2020

@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.

@kidunot89
Copy link
Member

@felipepxavier Any updates on this?

@felipepxavier
Copy link
Author

Hi, @kidunot89 !
I had to interrupt this project, so when I return I will give feedback here .. thanks!

@kidunot89
Copy link
Member

@felipepxavier Were you able to get the mutation working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants