wp-graphql-woocommerce icon indicating copy to clipboard operation
wp-graphql-woocommerce copied to clipboard

Stock quantity not decreased when creating an order.

Open vikramkh opened this issue 5 years ago • 2 comments

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.

vikramkh avatar Jul 02 '20 10:07 vikramkh

Have you tried using the checkout mutation instead?

(But the bug with createOrder will still be there)

zamson avatar Jul 02 '20 12:07 zamson

@vikramkh Any updates on this issue?

kidunot89 avatar Nov 24 '20 18:11 kidunot89