-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Take in account refunds when calculating Cost of Goods Sold for an order #57838
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
Conversation
Testing GuidelinesHi @prettyboymp @woocommerce/flux, Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
prettyboymp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested well. I didn't see anything specific that I have concerns with.
Looks like you'll need to apply an ignore comment to the lint rule. Preapproving.
|
@prettyboymp Thank you. Instead of adding a linting ignore for that |
Changes proposed in this Pull Request:
This pull request adds support for Cost of Goods Sold to orders with refunds:
calculate_cogs_total_valuefor an order will have the combined cost of the refunded items substracted.wc_create_refund./wp-json/wc/v3/orders/<order id>/refunds, note that it's for v3 only) now includes the cost value for the refund (the one substracted from the order cost) as well as the cost of each line item of the refund.woocommerce_order_item_cogs_per_item_tooltipfilter.Screenshots or screen recordings:
How to test the changes in this Pull Request:
Enable the Cost of Goods Sold feature (WooCommerce - Settings - Advanced - Features).
Create a few products with a non-zero value for the Cost of Goods field (see Add Cost of Goods Sold fields in product editors in admin #54399).
In the admin area create an order with the above products, about 10 units of each so that you can create multiple refunds.
Issue a few partial refunds. Verify that the "Cost" column now displays the individual cost of the refunded item times the number of refunded items.
Also verify that after creating each refund the total cost value of the order (displayed in the summary area under the order items as "Cost total") updates (gets decreased) accordingly.
Hover the mouse pointer in the "Cost" column of one of the line items with refunds and verify that the tooltip appears with the correct value.
You can test the new filter with the following snippet:
Issue a
GETrequest to the following REST API endpoint:/wp-json/wc/v3/orders/<order id>/refunds. Verify that there's a"cost_of_goods_sold"field with the correct value for each refund, and also for each product line item within each refund.Issue a
OPTIONSrequest to the same endpoint, verify that the"cost_of_goods_sold"fields for both the refunds and their line items get a proper schema entry.Changelog entry
Changelog Entry Details
Significance
Type
Message
Changelog Entry Comment
Comment