is there a way to ajax update basket content

584 views
Skip to first unread message

Michael Lind Hjulskov

unread,
Jul 28, 2014, 4:32:03 AM7/28/14
to django...@googlegroups.com
Hi

Is there a way to get and insert basket new content - I would like to update the basket contentt after ajax update of basket content.
maybe this is allready build in?
Or do I have to build that ?

David Winterbottom

unread,
Jul 28, 2014, 4:43:00 AM7/28/14
to django-oscar

You can verify this by watching the network tab in, say, firebug.


--
https://github.com/tangentlabs/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
---
You received this message because you are subscribed to the Google Groups "django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-oscar...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-oscar.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-oscar/8d6f9e9d-34fb-4191-854a-cf54036760af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
David Winterbottom
Technical Director

Tangent Snowball
84-86 Great Portland Street
London W1W 7NR
England, UK

Michael Lind Hjulskov

unread,
Jul 28, 2014, 5:42:16 AM7/28/14
to django...@googlegroups.com, david.win...@tangentlabs.co.uk
Interesting, thanks for pointing me to that.

But you misunderstood me
I meant the content in the basket-mini in right corner.
Would be great if I call something lik this, after changing qty :
new_content = ajax_get_basket_mini_content();
$(".basket-mini").html(new_content);

Michael Lind Hjulskov

unread,
Jul 28, 2014, 6:24:47 AM7/28/14
to django...@googlegroups.com, david.win...@tangentlabs.co.uk
I created this view in basket/views.py:

class BasketMiniViewAjax(TemplateView):

    template_name = "partials/mini_basket_ajax.html"

    def get_context_data(self, **kwargs):
        context = super(BasketMiniViewAjax, self).get_context_data(**kwargs)
        return context



this js function in my included js file:
function ajax_update_basket_mini(url_update_basket_mini){
   $.ajax({
        type: "GET",
        url: url_update_basket_mini,
        dataType: "html",
        cache: false,
        success: function(data) {
            if (data){
                //alert(data);
                $(".basket-mini").html(data);
                return true;
            }
        }
    });
}

added url in my basket/app.py:
basket_mini_ajax_view = views.BasketMiniViewAjax
... and 
url(r'^basket_mini_ajax/$', self.basket_mini_ajax_view.as_view(), name='ajax-basket-mini'),


calling the update to happen after basket qty is changed:
ajax_update_basket_mini("{% url 'basket:ajax-basket-mini' %}");

Michael Lind Hjulskov

unread,
Jul 28, 2014, 6:29:09 AM7/28/14
to django...@googlegroups.com, david.win...@tangentlabs.co.uk
and I created a new html file called partials/mini_basket_ajax.html
its actually just a copy of partials/mini_basket.html
where i just removed this starting and ending div:
<div class="basket-mini pull-right hidden-phone">
</div>

maybe this could be simplified somehow - i strongly believe so. Please let me know if you know howto remove these div tags using jquery

Alain Ivars

unread,
Aug 29, 2014, 8:34:12 AM8/29/14
to django...@googlegroups.com, david.win...@tangentlabs.co.uk
hi Michael,
I'm interested by the "ajax update basket" functionality, is your modification is on a branch on github ?

Nuruddin Iminohunov

unread,
Jun 26, 2016, 8:22:38 AM6/26/16
to django-oscar
Hello, i would like to add to basket while rendering product using button ,is there any way to addd it with ajax

Sergey Maranchuk

unread,
Jul 3, 2016, 6:28:58 AM7/3/16
to django-oscar
check https://github.com/django-oscar/django-oscar-api

воскресенье, 26 июня 2016 г., 15:22:38 UTC+3 пользователь Nuruddin Iminohunov написал:
Reply all
Reply to author
Forward
0 new messages