[ic] Load saved cart (but don't clobber)

Peter peter at pajamian.dhs.org
Thu Dec 24 01:50:56 UTC 2015


On 22/12/15 04:16, Grant wrote:
>>> Can I have the saved shopping cart associated with a user's account
>>> loaded when they log in but combined with the current cart contents
>>> instead of clobbering it?
>>
>> Just put in a postlogin_action that calls the [load-cart] tag, it
>> already merges by default, something like this in catalog.cfg should do
>> it I think (untested):
>>
>> UserDB default postlogin_action [load-cart]
> 
> 
> I switched from this:
> 
> [userdb function=get_cart nickname=shopping_cart]
> 
> to this:
> 
> [load-cart name=shopping_cart]
> 
> and it's merging but if the same item is in the current cart and
> loaded from the saved cart then they end up as separate line items.
> Can I have them either de-duplicated or incremented in quantity on the
> same line?

after the [load-cart] tag you would put in a [calcn] block that iterates
over the $Items hashref comparing the items and merging them
individually.  Just tweak the quantity field, adding on one item and
zeroing on the other, then you can toss cart which will remove all the
items with 0 quantity.


Peter



More information about the interchange-users mailing list