Beispiel #1
0
    def isValid(self, product=None):
        """Returns True if the entered coupon code is valid
        """
        shop = IShopManagement(self.context).getShop()
        cm = ICouponManagement(shop)

        if cm.getValidCoupon(self.context):
            return True
        else:
            return False
Beispiel #2
0
    def apply_code(self,action):
        data, errors = self.extractData()
        coupon_id = data.get('couponId','')
        context = aq_inner(self.context)
        cm = ICouponManagement(context)
        sm = IStatusMessage(self.request)

        if not coupon_id:
            self.status = _("please enter a valid coupon id")
            return

        try:
            cm.saveCouponConsumer(coupon_id.strip())
            sm.addStatusMessage(_("valid coupon consumed"))

            template_id = component.getMultiAdapter(
                (self.context,self.request),
                name="plone_context_state").current_page_url().split('/').pop()

            return self.request.response.redirect(template_id)
        except Exception, msg:
            # see easyshop.coupon.adapters.coupon_management for exceptions
            self.status = translate(_(str(msg)),
                target_language=self.request.get('LANGUAGE','de'))
Beispiel #3
0
 def get_coupon(self):
     """
     """
     cm = ICouponManagement(self.context)
     return cm.getValidCoupon()