Bug Report: Trashed product w/assigned generator
-
Problem:
After moving a product to trash with an assigned generator, the generator still shows the now-trashed product at the top of the edit page. Example: https://i.imgur.com/CCPGiSd.png.Steps to repro:
Create a variable product, with an assigned generator for each variation: https://i.imgur.com/SyXNibt.png. After publishing the product, and verifying that it is listed on the “Edit” page for that generator, move the product to trash, and refresh the generator “Edit” page. I would expect the same behavior from a Simple Product with an assigned generator, but have only tested it using a Variable Product.Possible solutions:
Verify that the proper action is being hooked for trashing products. AFAIK moving a woocommerce product to trash is handled the same as if it were a post, so most likely hookingwp_trash_post
would suffice. I haven’t inspected the source, but it’s possible the plugin may be usingwp_delete_post
hook (if any at all), which does not run when moving a post to trash (only when permanently deleting the post).Another (possibly better) method would be to simply check the product post’s status when querying the linked products for the generator’s edit page, and filtering which ones are displayed (or how they are displayed) based on the post status (example: https://i.imgur.com/MdA1MEx.png):
if ('trash' == get_post_status( $post_id )) { // skip this one, or suffix the product name with "(in trash)", etc }
- The topic ‘Bug Report: Trashed product w/assigned generator’ is closed to new replies.