Skip to content
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

Remove cart products on post or delete request #4723 #72

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1374,3 +1374,8 @@ span.text-success, span.text-warning, span.text-danger, span.text-info{
color: #b94a48;
text-decoration: none;
}
/* shopping_cart.jinja */
.action span i:hover{
cursor: pointer;
color: #AD4242;
}
11 changes: 10 additions & 1 deletion templates/webshop/shopping-cart.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</td>
<td class="action">
<a href="" data-toggle="tooltip" data-placement="top" title="" data-original-title="Move to Wishlist"><i class="fa fa-heart"></i></a>
<a href="{{ url_for('nereid.cart.delete_from_cart', line=line.id) }}" data-toggle="tooltip" data-placement="top" title="" data-original-title="{{ _('Remove Item') }}"><i class="fa fa-trash-o"></i></a>
<span data-url="{{ url_for('nereid.cart.delete_from_cart', line=line.id) }}" data-toggle="tooltip" data-placement="top" title="" data-original-title="{{ _('Remove Item') }}" class="remove_from_cart"><i class="fa fa-trash-o"></i></span>
</td>
</tr>
{% endfor %}
Expand Down Expand Up @@ -203,6 +203,15 @@
$("a.clear-cart").click(function(){
$(this).button('loading');
});
$('.remove_from_cart').on('click', function(){
$.ajax({
type: "DELETE",
url: $(this).data("url"),
})
.success(function(){
location.reload();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO you should not reload the page. Just flash a message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will have to reload the page because the cart totals change. Eventually the cart page has to be completely AJAX

});
});
});
</script>
{% endblock script_tags %}