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

line_items is empty while REST API Order refund. #50

Open
HolyWalley opened this issue Oct 9, 2019 · 2 comments
Labels

Comments

@HolyWalley
Copy link

@HolyWalley HolyWalley commented Oct 9, 2019

Describe the bug
Versions: wc 3.5.0, wp 4.7.14 php 7.2

I'm working on implementing partial order refunds through Rest API (using ruby client). According to the documentation I can specify line items which I want to refund. I've tried with different data but I always got empty(empty array) line_items field in the response. Then I created a new order and made a refund via the UI. It works. I copied data from this refund, created a new one, changed id's in the copied data and tried to refund the new order through API but it doesn't work.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new order and pay for it but a payment method that supports an automatical refund (I did it with PayPal sandbox), wait for the confirmation from PayPal.
  2. Try to refund one of the line items via Rest API using the structure from the documentation above.
  3. Check line_items field of created refund
  4. See an empty array

Example body:

{
  "amount": "25.00",
  "reason": "",
  "refunded_payment": true,
  "meta_data": [],
  "line_items": [
    {
      "name": "Long Sleeve Tee",
      "product_id": 68,
      "variation_id": 0,
      "quantity": -1,
      "tax_class": "",
      "subtotal": "-25.00",
      "subtotal_tax": "0.00",
      "total": "-25.00",
      "total_tax": "0.00",
      "taxes": [],
      "meta_data": [
        {
          "key": "_refunded_item_id",
          "value": "114"
        }
      ],
      "sku": "woo-long-sleeve-tee",
      "price": 25
    }
  ]
}

I'm doing a post request with this body to /orders/:order_id/refunds.

Expected behavior
It creates a refund that contains a non-empty line_items field.

Screenshots

That's how the order should look like from UI
https://yadi.sk/i/X393MXb6jc18aw

But it looks like that:
https://yadi.sk/i/FNMhTSfteko81w

P.S. I've also found a similar 2 years old issue but without an answer.

@claudiosanches claudiosanches transferred this issue from woocommerce/woocommerce Oct 9, 2019
@issue-label-bot

This comment has been minimized.

Copy link

@issue-label-bot issue-label-bot bot commented Oct 9, 2019

Issue-Label Bot is automatically applying the label type: bug to this issue, with a confidence of 0.86. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@issue-label-bot issue-label-bot bot added the type: bug label Oct 9, 2019
@HolyWalley

This comment has been minimized.

Copy link
Author

@HolyWalley HolyWalley commented Oct 10, 2019

well, now I see the answer here #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.