wp-graphql / wp-graphql-woocommerce

Add WooCommerce support and functionality to your WPGraphQL server
https://woographql.com
GNU General Public License v3.0
638 stars 129 forks source link

Stock quantity not decreased when creating an order. #313

Open vikramkh opened 4 years ago

vikramkh commented 4 years ago

If you create an order through the dashboard, and mark it as complete, it will substract the quantity of the items in the order from the stock quantity. However, when creating an order through graphql, marked as paid and complete, it will not subtract the quantity of the item from the stock quantity.

I ran this query:

mutation MyMutation {
  __typename
  createOrder(input: {clientMutationId: "uniqueId", lineItems: {quantity: 3, productId: 3007}, status: COMPLETED, isPaid: true, paymentMethod: "cash", transactionId: "123", currency: "USD"}) {
    order {
      lineItems {
        nodes {
          product {
            name
            ... on SimpleProduct {
              id
              name
              stockQuantity
            }
          }
        }
      }
    }
  }
}

and the stock quantity returned as well as the one in the database was not changed after running the query.

Expected behaviour: It should behave as the portal behaves, when creating an order as completed, the product quantity should be subtracted from stock quantity.

zamson commented 4 years ago

Have you tried using the checkout mutation instead?

(But the bug with createOrder will still be there)

kidunot89 commented 3 years ago

@vikramkh Any updates on this issue?