Add wishlist delete button

This commit is contained in:
Jay Trees 2022-01-17 14:18:01 +01:00
parent 24f592f954
commit 4a56be73f9
2 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,7 @@
$(function() {
$('.ui.dropdown.wishlists').on('change', function() {
$('[name="wishlist_delete_id"]').val(
$('.ui.dropdown.wishlists').dropdown('get value')
);
});
});

View file

@ -20,6 +20,15 @@ if (isset($_GET['wishlist'])) {
$wishlist = $_GET['wishlist'];
$products = $user->getProducts($wishlist);
}
/**
* Delete wishlist
*/
if (isset($_POST['wishlist_delete_id'])) {
$database->query('DELETE FROM `wishlists`
WHERE id = ' . $_POST['wishlist_delete_id'] . '
;');
}
?>
<main>
<div class="ui container">
@ -49,6 +58,15 @@ if (isset($_GET['wishlist'])) {
<i class="share icon"></i>
Share
</button>
<form class="ui form" method="post">
<input type="hidden" name="wishlist_delete_id" />
<button class="ui small labeled red icon button" type="submit">
<i class="trash icon"></i>
Delete
</button>
</form>
</div>
</div>