From e4159a95428accbd43f91f44d568d7afff72fc95 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Thu, 4 Sep 2014 23:18:05 +0200 Subject: [PATCH] =?utf8?q?Impl=C3=A9mentation=20de=20la=20remise.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- order.py | 8 +++++++- skins/order_view.py | 1 + skins/order_view_template.pt | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/order.py b/order.py index db19cc0..6966ff3 100755 --- a/order.py +++ b/order.py @@ -183,6 +183,7 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) : self.id = id self.items = [] self.quantity = 0 + self.discount = 0 # discount ratio in percent self.price = Price(0, 0) # billing and shipping addresses self.billing = PersistentMapping() @@ -192,7 +193,8 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) : @property def amountWithFees(self) : - return self.price + self.shippingFees + coeff = (100 - self.discount) / 100. + return self.price * coeff + self.shippingFees security.declareProtected(ModifyPortalContent, 'editBilling') @@ -223,6 +225,7 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) : pptool = getToolByName(self, 'portal_photo_print') uidh = getToolByName(self, 'portal_uidhandler') mtool = getToolByName(self, 'portal_membership') + utool = getToolByName(self, 'portal_url') items = [] for item in cart : @@ -251,6 +254,9 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) : counters.confirm(reference, quantity) self.items = tuple(items) + discount_script = getattr(utool.getPortalObject(), 'photoprint_discount', None) + if discount_script : + self.discount = discount_script(self.price, self.quantity) member = mtool.getAuthenticatedMember() mg = lambda name : member.getProperty(name, '') diff --git a/skins/order_view.py b/skins/order_view.py index 308844c..1930d31 100755 --- a/skins/order_view.py +++ b/skins/order_view.py @@ -55,6 +55,7 @@ for item in context.items : options['infos'] = infos options['quantity'] = quantity options['pricesSum'] = context.price +options['discount'] = getattr(context, 'discount', 0) options['shippingFees'] = shippingFees = context.shippingFees options['total'] = context.amountWithFees diff --git a/skins/order_view_template.pt b/skins/order_view_template.pt index 5f748b2..96e6c4a 100644 --- a/skins/order_view_template.pt +++ b/skins/order_view_template.pt @@ -129,6 +129,10 @@ + + Discount + % + Shipping -- 2.20.1