handle product options correctly
This commit is contained in:
parent
12a5b339ad
commit
620bf6fe25
2 changed files with 7 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
#-*- coding: UTF-8 -*-
|
#-*- coding: UTF-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -408,12 +408,13 @@ class IOrderItem(ITrack):
|
||||||
shop = Attribute(u'The shop from which the product is ordered.')
|
shop = Attribute(u'The shop from which the product is ordered.')
|
||||||
order = Attribute(u'The order this order item belongs to.')
|
order = Attribute(u'The order this order item belongs to.')
|
||||||
unitPrice = Attribute(u'The basic unit price for one of the product '
|
unitPrice = Attribute(u'The basic unit price for one of the product '
|
||||||
u'items ordered.')
|
u'ites ordered.')
|
||||||
fullPrice = Attribute(u'The full price for the quantity ordered.')
|
fullPrice = Attribute(u'The full price for the quantity ordered.')
|
||||||
quantityShipped = Attribute(u'The total quantity that has been shipped '
|
quantityShipped = Attribute(u'The total quantity that has been shipped '
|
||||||
u'already.')
|
u'already.')
|
||||||
shippingInfo = Attribute(u'A list of mappings, with fields like: '
|
shippingInfo = Attribute(u'A list of mappings, with fields like: '
|
||||||
u'shippingId, shippingDate, quantity, packageId')
|
u'shippingId, shippingDate, quantity, packageId')
|
||||||
|
options = Attribute(u'Product options associated with this order item.')
|
||||||
|
|
||||||
def remove():
|
def remove():
|
||||||
""" Remove the order item from the order or cart.
|
""" Remove the order item from the order or cart.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Order and order item classes.
|
Order and order item classes.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.app.intid.interfaces import IIntIds
|
from zope.app.intid.interfaces import IIntIds
|
||||||
|
@ -118,7 +116,10 @@ class OrderItems(object):
|
||||||
|
|
||||||
def add(self, product, party, shop, order='???', run=0, **kw):
|
def add(self, product, party, shop, order='???', run=0, **kw):
|
||||||
kw['shop'] = self.getUid(shop)
|
kw['shop'] = self.getUid(shop)
|
||||||
|
options = kw.get('options', [])
|
||||||
existing = self.getCart(party, order, shop, run, product=product)
|
existing = self.getCart(party, order, shop, run, product=product)
|
||||||
|
existing = [item for item in existing
|
||||||
|
if (item.data.get('options') or []) == options]
|
||||||
if existing:
|
if existing:
|
||||||
track = existing[-1]
|
track = existing[-1]
|
||||||
track.modify(track.quantity + kw.get('quantity', 1))
|
track.modify(track.quantity + kw.get('quantity', 1))
|
||||||
|
|
Loading…
Add table
Reference in a new issue