How can I remove an item from the customer's basket in django oscar?
The following line just acts as an <a href="#"></a>
link:
<a href="#" data-id="{{ forloop.counter0 }}" data-behaviours="remove" class="inline">{% trans "Remove" %}</a>
How can I remove an item from the customer's basket in django oscar?
The following line just acts as an <a href="#"></a>
link:
<a href="#" data-id="{{ forloop.counter0 }}" data-behaviours="remove" class="inline">{% trans "Remove" %}</a>
In Python, if you know the line of which item to delete:
request.basket.items[line].delete()
request.basket.save()
In JavaScript, look at https://github.com/django-oscar/django-oscar/blob/master/oscar/static/oscar/js/oscar/ui.js#L177-180 for the lines of code that trigger the item removal:
$('#content_inner').on('click', '#basket_formset a[data-behaviours~="remove"]', function(event) {
o.basket.checkAndSubmit($(this), 'form', 'DELETE');
event.preventDefault();
});
Some more possibly helpful reading: email thread about python deletion and email thread about js deletion.