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
Fix duplicate product endpoint args for item schema #46551
Conversation
Hi @jorgeatorres, @woocommerce/mothra Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
@@ -99,10 +99,6 @@ public function duplicate_product( $request ) { | |||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) ); | |||
} | |||
|
|||
if ( 'simple' !== $product->get_type() ) { |
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.
I removed this because it's not necessary anymore.
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.
LGTM @octaedro nice job!
* Fix endpoint args for item schema * Add tests * Add changelog
Submission Review Guidelines:
Changes proposed in this Pull Request:
This PR fixes an error related to the duplicate product REST API endpoint. The method was working well but it did not duplicate the stock management option.
That was happening because we sent the wrong param to
get_endpoint_args_for_item_schema
.This PR adds some unit tests and fixes the bug.
Product
type
andstatus
are not editable.Closes #46535.
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Duplicate
andDuplicate and modify
. After pressing any of them, a prompt asking for aProduct ID
to duplicate will be visible. After adding a product ID and pressing ok, it will send a request to/wp-json/wc/v3/products/[your-product-id]/duplicate
.Console
tab.Duplicate
and add the ID of the simple product to the prompt. If everything goes well you'll see the duplicated product printed in the console.(Copy)
at the endDraft
.Products > All Products
and find the duplicated product there.Products > All Products
. Verify that the variations were duplicated correctly (the prices set in step 1 should match).Duplicate and modify
and add the ID of the simple product to the prompt. If everything goes well you'll see the duplicated product printed in the console. This option also sends a description of the product, so the duplicated product's description should say: "This is my description".Changelog entry
Significance
Type
Message
Comment