Hi all,

I had to update satchmo and the settings showed up in store settings.
But even after enabling it, it never loaded my previous cartitems
unless I added an item to the cart and then login.
I altered the function _get_prev_cart in satchmo_store/accounts/
views.py.
I removed the "and request.session['cart']" from the if statement the
new function looks like this:
def _get_prev_cart(request):
    try:
        contact = request.user.contact_set.get()
        saved_cart = contact.cart_set.latest('date_time_created')
        # If the latest cart has len == 0, cart is unusable.
        if len(saved_cart):
            # Merge the two carts together
            existing_cart = Cart.objects.from_request(request,
create=False)
            if len(existing_cart):
                saved_cart.merge_carts(existing_cart)
            request.session['cart'] = saved_cart.id
    except Exception, e:
        pass

Now at login if I have an empty cart and I login it will load my
previous cart items and
also if I add items to the cart before login, after I login it
combines the cart items.

Could someone more knowledge able look over this code and make sure it
will not cause me trouble down the road,
Is there any drawback doing it this way?

Thank you

lzantal

On Jan 20, 10:52 pm, lzantal <[email protected]> wrote:
> Hi all,
>
> Digging around in satchmo_store/accounts/view.py I find this in _login
> if config_value('SHOP','PERSISTENT_CART'):
>                     _get_prev_cart(request)
>
> Is satchmo all ready has persistent cart?
> Now I just need to find it where to set that setting.
>
> lzantal
>
> On Jan 20, 10:34 pm, lzantal <[email protected]> wrote:
>
> > Hi all,
>
> > I am working on a cart save function.
> > I can't find  any signal that gets sent before the logout takes place.
> > Could someone please point me to the right direction?
> > I find the logout url uses the default
> > 'django.contrib.auth.views.logout' view in
> > satchmo_store/accounts/urls.py
> > If there is no signal for it would something this work.:
> > overwrite the logout url to catch it before satchmo does. Save the
> > cart items in my custom view and then call the original logout view.
>
> > Thank you for all the help
>
> > lzantal
-- 
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en.


Reply via email to