Example #1
0
 def init(self, promo=None):
     # create cart on acct creation
     c = Cart(parent=self.key)
     if promo:
         c.populate(code=promo.key, promo=promo.amount)
         # give credit to referrer
         if promo.user:
             UserCredit(referral=self.key, parent=promo.user, amount=promo.amount).put()
     c.put()
     PromoCode(user=self.key, code=str(self.key.id())[-4:], amount=10.00).put()
     # UserStats(parent=self.key, refcode=str(self.key.id())[-4:]).put()
     return
Example #2
0
 def cart_total(self):
     c = Cart.query(ancestor=self.key).get()
     if c:
         return c.item_count()
     else:
         return 0