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
Modify the logic for deleting variations #27137
Conversation
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.
@codestor4 This has the potential to change behaviour for third party product types. This could be implemented as a filter that defaulted to the current logic. WC Subs could use that filter to bypass removing the variations.
Implements the following expected behaviour: 1. Switch from variable subscription to non-variable one will delete variations. 2. Switch from variable subscription to variable product and vice-versa will NOT delete any variations. This shall have no side-effects in WooCommerce Core.
abc83a9
to
4ecb468
Compare
This will introduce two new filters: woocommerce_from_product_type_changed woocommerce_to_product_type_changed to filter the $from and $to variables respectively. This will be useful in WCS pr_3732!
Thanks for the feedback @rrennick. I have made the necessary changes now. The newly introduced filters will be used as follows in https://github.com/woocommerce/woocommerce-subscriptions/pull/3732:
I've tested this and it works. I'll be adding it to the pull request mentioned above after this current pull request gets merged. |
Removing the two newly introduced filters and replacing it with one single filter: woocommerce_delete_variations_on_product_type_change.
Update: I have removed the two filters and replaced it with one. It still achieves the same end goal. |
Hey @rrennick, no rush but could you review this once again when you have some time? Thx :) |
Hi @codestor4, the change looks fine but it would be great if you could add a documentation comment for the newly added filter. See an example here: https://github.com/woocommerce/woocommerce/blob/master/includes/admin/meta-boxes/views/html-variation-admin.php#L165-L174 (please use version 4.9 for the |
Updated @SInCE to 4.9 and added an inline doc for the new filter 'woocommerce_delete_variations_on_product_type_change'
@Konamiman I've made the requested changes. Please review and let me know! 👍 |
@abhishek-pokhriyal It's ready for a review 👍 |
Approved. @rrennick do you want to take a second look before merging? |
@codestor4 Sorry for the delays in getting this through review. |
Summary
Implements the following expected behavior which fixes an issue with Subscriptions:
This shall have no side-effects in WooCommerce Core.
All Submissions:
Changes proposed in this Pull Request:
Closes #26959.
Closes https://github.com/woocommerce/woocommerce-subscriptions/issues/3672
How to test the changes in this Pull Request:
This was originally pushed to WC Subscriptions but it makes more sense to add it directly to WooCommerce. Testing instructions are therefore available in WC Subscriptions PR: https://github.com/woocommerce/woocommerce-subscriptions/pull/3795.
Other information:
Changelog entry