Skip to content

Commit

Permalink
Add actions before and after deleting product(s). (#2368)
Browse files Browse the repository at this point in the history
  • Loading branch information
decodekult authored Oct 24, 2024
1 parent ead0858 commit 7b317f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions includes/Dashboard/Templates/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@ public function handle_delete_product() {
exit;
}

do_action( 'dokan_product_delete', $product_id );

dokan()->product->delete( $product_id, true );

do_action( 'dokan_product_deleted', $product_id );
Expand Down
2 changes: 2 additions & 0 deletions includes/Product/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,13 @@ public function bulk_product_delete( $action, $products ) {
return;
}

do_action( 'dokan_product_bulk_delete', $products );
foreach ( $products as $product_id ) {
if ( dokan_is_product_author( $product_id ) ) {
dokan()->product->delete( $product_id, true );
}
}
do_action( 'dokan_product_bulk_deleted', $products );

wp_safe_redirect( add_query_arg( [ 'message' => 'product_deleted' ], dokan_get_navigation_url( 'products' ) ) );
exit;
Expand Down

0 comments on commit 7b317f1

Please sign in to comment.